Changing color of density plots in ggplot2
I've got a nifty pair of probability density functions I created with ggplot2 as follows:
require(ggplot2)
set.seed(2)
data <- rbind( data.frame(type="a", lr=rnorm(100)), data.frame(type="b", lr=rnorm(100,.5,1.2)))
m <- ggplot(data, aes(x=lr))
m <- m + geom_density(aes(fill=factor(type)), size=2, alpha=.4)
m
and that produces a nice plot:
However I would really like that plot to have different color shading. I can't seem to figure it out. I thought the following would work:
开发者_运维问答m + scale_colour_manual( values = c("red","blue"))
But no luck. I also tried passing fill colors to the geom_density() call, to no avail.
How do I change the fill colors?
Start kicking yourself:
m + scale_fill_manual( values = c("red","blue"))
精彩评论