Skip to content

Instantly share code, notes, and snippets.

@emhart
Created June 12, 2012 21:10
Show Gist options
  • Save emhart/2920156 to your computer and use it in GitHub Desktop.
Save emhart/2920156 to your computer and use it in GitHub Desktop.
Just to answer a ggplot Q
sm.q <- ddply(master.sm,.(noise,allee,cat),numcolwise(median),na.rm=T)
sm.names <- ddply(master.sm,.(allee,noise),numcolwise(median),na.rm=T)
sm.names <- sm.names[,1:2]
sm.names$aslope <- c(rep(-1.879652,5),rep(-1.584475,5))
sm.q$ltype <- as.factor(rep(2,dim(sm.q)[1]))
sm.slope <- ggplot(master.sm, aes(x=meanslope,group=cat,fill=cat)) +geom_density(alpha=.5)+xlim(-3,0)+facet_grid(noise~allee,scale="free_y")+opts(axis.ticks = theme_blank(), axis.text.y = theme_blank())+scale_fill_manual("Catastrophe \n size",values=c("red","blue","black"))+xlab("Mean Slope")+ylab("Density")
sm.slope <- sm.slope+ geom_vline(aes(xintercept=-1),color="red", linetype="dashed", size=.3)
sm.slope <- sm.slope + geom_vline(data=sm.q,aes(xintercept=meanslope,color=cat,linetype="dashed"))+facet_grid(noise~allee,scales="free_y")+scale_colour_manual(values=c("red","blue","black"),legend= F)
sm.slope <- sm.slope + geom_vline(data=sm.names,aes(xintercept=aslope,legend=F,linetype="dashed",size=.8))+facet_grid(noise~allee,scales="free_y")
sm.slope + theme_blk()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment