[R] ggplot2: edge outlines on points

hadley wickham h.wickham at gmail.com
Wed Sep 10 17:09:35 CEST 2008


Hi Adam,

The next version of ggplot2 supports the build-in R plotting symbols
that have different fills and borders, so you can do something like:

geom_point(aes(colour=TRT), fill="red", colour="black", shape=21)

Otherwise in the current version you can do:

ggplot(data.frame(x = runif(20), y = runif(20)), aes(x, y)) +
geom_point(size = 3, colour = "black") +
geom_point(size = 2, colour = "red")

The key difference to your code is that it's all on one plot, and I'm
manually setting the colours, rather than to using scales.  I also
just used a smaller point rather than the matching hollow glyph, which
makes things a little easier (and reverses the orders of the colours).

Hadley

On Wed, Sep 10, 2008 at 9:37 AM, Adam Marsh <amarsh at udel.edu> wrote:
> The graphic design elements in ggplot2 are so well done for color
> graphics. Thank you! For BW publication graphs, there are a few
> options I would like to be able to tweak, but can't seem to find the
> grob handles necessary OR the right plotting strategy. Here's one
> problem I've been puzzling over:
>
> Q> How do you plot points with a grey fill and a black outline around
> the edge?
>
> I haven't been able to find the MatLab equivalent of
> "MarkerEdgeColor" so
> I've been working on trying to overlay two plots of the same points,
> one plotted with fills and the other plotted with edge outlines (here
> is my conceptual  code):
>
> pfill <- ggplot(data=DF, aes(x=X, y=Y)) +
>             geom_point(aes(colour=TRT),size=4) +
>             scale_colour_grey(end=0.8) +
>             theme_bw
>
> pedge <- ggplot(data=DF, aes(x=X, y=Y)) +
>             geom_point(aes(colour=TRT),size=4) +
>             scale_colour_grey(end=0.8) +
>             scale_shape(solid=FALSE) +
>             theme_bw
>
> However, I can't figure out the correct syntax, if this is even the
> right way to go about it. Any suggestions as to the best approach to
> achieve filled points with an edge outline would be greatly appreciated.
>
>
> ---------------------------------------------------
> Adam G. Marsh, Ph.D.
> Associate Professor
> Marine Biological Sciences
> University of Delaware
> Lewes, DE 19958
> 302.645.4367
> ------------------------------------------------
>
>
>
>
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



-- 
http://had.co.nz/



More information about the R-help mailing list