值我想繪製鏡像95%的密度曲線和映射α位密度:GGPLOT2:設置(非線性)用於α-
foo <- function(mw, sd, lower, upper) {
x <- seq(lower, upper, length=500)
dens <- dnorm(x, mean=mw, sd=sd, log=TRUE)
dens0 <- dens -min(dens)
return(data.frame(dens0, x))
}
df.rain <- foo(0,1,-1,1)
library(ggplot2)
drf <- ggplot(df.rain, aes(x=x, y=dens0))+
geom_line(aes(alpha=..y..))+
geom_line(aes(x=x, y=-dens0, alpha=-..y..))+
stat_identity(geom="segment", aes(xend=x, yend=0, alpha=..y..))+
stat_identity(geom="segment", aes(x=x, y=-dens0, xend=x, yend=0, alpha=-..y..))
drf
這工作得很好,但我想使邊緣和中間的對比更加突出,即我希望邊緣幾乎是白色的,只有中間部分是黑色的。我一直在篡改scale_alpha()
,但沒有運氣。有任何想法嗎?
編輯:最終,我想繪製幾個雨滴,即單個滴劑會很小,但陰影仍應清晰可見。
+1例如代碼! – 2012-07-31 10:33:58