[R] black and white in qplot? layout 4 graphs in one screen

rachaelohde cox.rachael at gmail.com
Wed Dec 21 21:16:46 CET 2011


Hello, 

I am trying to plot means and standard errors conditioned by a factor, using
qplot.  I am successful at getting the bar graph I want with a error bar,
however I have tried many things and cannot get the bars to change colors. 
Currently showing as red and blue, but need it to be black and white for
publication.  Any suggestions please?  

Using a data set June, which is str:
'data.frame':   21 obs. of  6 variables:
 $ BLCK     : Factor w/ 4 levels "","B","I","W": 3 4 2 3 2 2 2 4 3 4 ...
 $ PLOT     : int  3 3 6 1 2 5 1 1 2 2 ...
 $ TRT      : Factor w/ 5 levels "","crop","ten",..: 2 2 2 3 3 3 4 4 4 5 ...
 $ Date     : Factor w/ 8 levels ""," 6/16/11",..: 2 2 2 2 2 2 2 2 2 2 ...
 $ habitat  : Factor w/ 3 levels "","C","P": 2 2 2 2 2 2 2 2 2 2 ...
 $ Abundance: num  0.333 0 1.333 0 1.667 ...

Current code is: 

Ab.avg<-ddply(June, c("TRT", "habitat"), function(df)
 return(c(Ab.avg=mean(df$Abundance), Ab.sd=sd(df$Abundance))))

avg.plot<-qplot(TRT, Ab.avg, fill=factor(habitat), 
data=Ab.avg, geom="bar", position="dodge")

dodge <- position_dodge(width=0.9)
avg.plot++geom_linerange(aes(ymax=Ab.avg+Ab.sd, ymin=Ab.avg-Ab.sd),
position=dodge)+theme_bw()

http://r.789695.n4.nabble.com/file/n4223035/june_bar_graph.png 

Also, would like to plot 4 of these bar graphs (for four dates) on the same
screen, I cannot get the par() or layout() function to work with qplot.  Is
there another way?  

Thank you!

--
View this message in context: http://r.789695.n4.nabble.com/black-and-white-in-qplot-layout-4-graphs-in-one-screen-tp4223035p4223035.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list