r - How to get ggplot ecdf to plot with filled background -
i'm trying empirical cumulative density curves have backgrounds filled can't seem going.
i've tried next 2 approaches, first appears alter alpha of curve , not fill
ggplot( mydataframe , aes( x=myvariable , fill=myfactor ) ) + geom_step ( stat="ecdf" , aes( colour = myfactor ) , alpha=1 ) + coord_cartesian( xlim = c( 0 , quantile( mydataframe$myvariable , prob=0.99 ) ) ) + facet_grid ( myfactor ~ . , scales="free_y" )
the sec appears equilavent above
ggplot( mydataframe , aes( x=myvariable , fill=myfactor ) ) + stat_ecdf ( aes( colour = myfactor ) ,alpha=0.2 ) + coord_cartesian( xlim = c( 0 , quantile( mydataframe$myvariable , prob=0.99 ) ) ) + facet_grid ( myfactor ~ . , scales="free_y" )
i wonder if fill 100% across total xlim factor levels saturate early.
something this?
library(ggplot2) set.seed(1) df <- data.frame(var=c(rnorm(1000),rpois(1000,25),rgamma(1000,25)), fact=rep(c("n","p","g"),each=1000)) ggplot(df,aes(x=var,fill=fact))+ stat_ecdf(aes(ymin=0,ymax=..y..),geom="ribbon")+ stat_ecdf(geom="step")+ facet_grid(fact~.,scales="free_y")
r plot ggplot2
No comments:
Post a Comment