I am trying to plot points with two legends, one for the shape and one
for the fill, like the code below.
pl <- ggplot()
pl <- pl + geom_point(data = mps2, aes(x=mu, y=mps2_mu, fill =
factor(beta), shape = factor(L)), size = 3) +
scale_fill_grey(start=0.4, end=0.8) + scale_shape_manual(values =
c(21,24))
pl <- pl + labs(x = "x", y="y", shape="L", fill=expression(beta))
Points are plotted properly, legend titles are fine, and the legend
for shape is fine. However, the legend for fill shows solid black
dots, not the 2 shades of grey fill I expect. Any suggestions for what
I should change?
I am using ggplot2 version 0.8.6, R version 2.9.2.
best,
Siebren Reker
Unless someone knows how to specify a shape for scale_fill, my
workaround would be:
ggplot(mtcars, aes(mpg, wt, shape=factor(cyl))) +
geom_point(size=3) +
# only needed if you want
# solid black edge around the dots
geom_point(aes(colour=factor(vs))) +
# faking the fill effect
scale_colour_grey(start=0.5, end=0.9)
Xie Chao
> --
> You received this message because you are subscribed to the ggplot2 mailing list.
> To post to this group, send email to ggp...@googlegroups.com
> To unsubscribe from this group, send email to
> ggplot2+u...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/ggplot2
best,
Siebren
It seems to me that the legend should use pch=21 by default to avoid
this small bug,
GeomPoint$default_aes <- function(.) aes(shape=21, colour="black",
size=2, fill = NA, alpha = 1)
Best,
baptiste
Changing the default shape aesthetic isn't a good idea because it will
make all existing scatterplots use hollow points! I think this needs
a tweak to the legend code, but no one has provided a reproducible
example :(
Hadley
--
Assistant Professor / Dobelman Family Junior Chair
Department of Statistics / Rice University
http://had.co.nz/
ggplot(mtcars, aes(mpg, wt, shape=factor(cyl))) +
geom_point(aes(fill=factor(vs))) +
scale_fill_grey(start=0.5, end=0.9) +
scale_shape_manual(values =c(21,22,24)) +
theme_bw()
Best,
baptiste
ggplot(mtcars, aes(mpg, wt, shape=factor(cyl))) +
geom_point(aes(fill=factor(vs))) +
scale_shape_manual(values =c(21,22,24))
;)
But it got me on the right track and it will be fixed in the next version.
Hadley