答案 0 :(得分:4)
也许是这样的......
dat = data.frame(x=rnorm(1000))
ggplot(dat,aes(x=x)) +
geom_histogram(aes(y=..density..,fill="Histogram"),binwidth=0.5) +
stat_function(fun = dnorm, aes(colour= "Density")) +
scale_x_continuous('x', limits = c(-4, 4)) +
opts(title = "Histogram with Overlay") +
scale_fill_manual(name="",value="blue") +
scale_colour_manual(name="",value="red") +
scale_y_continuous('Frequency')+
opts(legend.key=theme_rect(fill="white",colour="white"))+
opts(legend.background = theme_blank())
注意:由于版本0.9.2 opts
已replaced theme
。例如,上面的最后两行是:
theme(legend.key = element_rect(fill = "white",colour = "white")) +
theme(legend.background = element_blank())