[R] How to add legend to 2 different data frame overplot?

C W tmrsg11 at gmail.com
Sat Oct 31 05:10:31 CET 2015


Hi,

I am trying to do add a legend to an overplot, something like this:

ggplot() +
    geom_density(data = df1, aes(x = x), fill = "green", show_guide =
FALSE) +
    geom_area(data = df2, aes(x = x), fill = "yellow", show_guide = FALSE) +
    scale_color_manual(values = c("green", "yellow"), labels = c('df1',
'df2'))

But the legend doesn't actually show up when I plot it.  How should I fix
this?

	[[alternative HTML version deleted]]



More information about the R-help mailing list