Hi Hadley, recently I run this code however got following error (this error seems not be there at 1st time) :
> dat <- data.frame(x = rnorm(100)) > dat1 <- data.frame( + x = c(0,0), + y = c(1,0), + Label = c("Point1", "Point2") + ) > > > ggplot(dat, aes(x)) + + geom_histogram(aes(fill = ..count..)) + + geom_point(aes(x, y, colour = Label), data = dat1, size = 4) + + scale_fill_gradient("Count", low = "green", high = "red", legend=F) stat_bin: binwidth defaulted to range/30. Use 'binwidth = x' to adjust this. Error in col2rgb(colour, TRUE) : invalid color name 'Point1' Am I missing something? I would also like to know how to put legend for "Points", but not for Histogram? Dose latest version allow me to do that? I am using following version of ggplot2 : > packageDescription("ggplot2") Package: ggplot2 Type: Package Title: An implementation of the Grammar of Graphics Version: 0.8.5 Author: Hadley Wickham <h.wick...@gmail.com> Maintainer: Hadley Wickham <h.wick...@gmail.com> ................................... Any suggestion will be highly appreciated. Thanks, hadley wickham wrote: > > You mean: > > dat <- data.frame(x = rnorm(100)) > dat1 <- data.frame( > x = c(0,0), > y = c(1,0), > Label = c("Point1", "Point2") > ) > > > ggplot(dat, aes(x)) + > geom_histogram(aes(fill = ..count..)) + > geom_point(aes(x, y, colour = Label), data = dat1, size = 4) + > scale_fill_gradient("Count", low = "green", high = "red") > > > Unfortunately not. In the future, you will be able to do + > scale_colour_discrete(legend = F) > > Hadley > > On Mon, Dec 7, 2009 at 11:17 AM, Megh <megh700...@yahoo.com> wrote: >> >> Here I have following code : >> >> dat = rnorm(100) >> ggplot() + geom_histogram(aes(dat, fill=..count..)) + >> scale_fill_gradient("Count", low="green", high="red") + >> opts(legend.position="none") >> # Above is without any legend >> >> ## Now I want to place two points with legends >> dat1 <- data.frame(c(0,0), c(1,0)); Label <- c("Point1", "Point2") >> last_plot() + geom_point(aes(dat1[,1], dat1[,2], colour=Label), size=4) >> # Here I am not getting any legend for "points" >> >> I want GGPLOT should show the legend for "points" NOT for "histogram". Is >> there any option? >> >> Thanks, >> >> -- >> View this message in context: >> http://n4.nabble.com/GGPLOT-Legends-at-different-layers-tp954527p954527.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. >> > > > > -- > http://had.co.nz/ > > ______________________________________________ > 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. > > -- View this message in context: http://n4.nabble.com/GGPLOT-Legends-at-different-layers-tp954527p979185.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.