Re: [R] How to add legend to 2 different data frame overplot?
Hi C W, I would guess you are trying to use the base graphics "legend" function. Have you tried one of the scale_* functions in ggplot? Jim On Sat, Oct 31, 2015 at 3:10 PM, C Wwrote: > 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]] > > __ > R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see > 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. > [[alternative HTML version deleted]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
Re: [R] How to add legend to 2 different data frame overplot?
Remove show_guide = FALSE? --- Jeff NewmillerThe . . Go Live... DCN:Basics: ##.#. ##.#. Live Go... Live: OO#.. Dead: OO#.. Playing Research Engineer (Solar/BatteriesO.O#. #.O#. with /Software/Embedded Controllers) .OO#. .OO#. rocks...1k --- Sent from my phone. Please excuse my brevity. On October 30, 2015 9:10:31 PM PDT, C W wrote: >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]] > >__ >R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see >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. __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.
[R] How to add legend to 2 different data frame overplot?
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]] __ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see 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.