2
我有這樣的直方圖GGPLOT2創建:如何繪製填充直方圖及其與ggplot2的密度?
x = rnorm(100,0,150)
df <- data.frame(val=c(x))
ggplot(df, aes(val,..density.., fill = ..x..>100)) +
geom_histogram(binwidth=bw.SJ(df$val), colour="black") +
scale_fill_hue(h=c(115,230))
我想向PDF添加到這個柱狀圖,但當下一行補充說:
geom_density(colour="red", lwd=1) +
這將返回錯誤:
Error in get(x, envir = this, inherits = inh)(this, ...) :
Aesthetics can not vary with a ribbon
在此先感謝!