Still struggling with this. A further example using a slightly different
organisation of the data. The factors "A" and "B" are included in the
dataframe in an attempt to get ggplot to generate a legend automatically.

x <- data.frame(value=rnorm(5000, mean=0), case="A")
y <- data.frame(value=rnorm(5000, mean=3), case="B")
xy <- rbind(x, y)
ggplot(xy, aes(x=value, fill=case, group=case)) +
geom_histogram(binwidth=0.1)
ggplot(xy, aes(x=value, fill=case, group=case)) + geom_density(alpha=0.2)

Whilst the legend is generated as expected the histogram and density plots
are different. The density plots overlap each other whereas the histogram
plots stack. I'm trying the get the histogram plots to overlap, and retain
the legend. Is the histogram stacking by design? Can stacking be changed to
overlapping?



-- 
View this message in context: 
http://www.nabble.com/ggplot2-legend-problem-tp25036665p25037500.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help@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.

Reply via email to