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 <megh700004 at 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 at 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/