[R] [GGPLOT] Legends at different layers

Megh megh700004 at yahoo.com
Mon Dec 7 18:17:37 CET 2009


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.




More information about the R-help mailing list