black and white in qplot? layout 4 graphs in one screen
Hi,
On 22 December 2011 09:16, rachaelohde <cox.rachael at gmail.com> wrote:
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?
Have a look at scale_fill_grey() and grid.arrange() d= data.frame(x=sample(letters[1:4], 10, replace=TRUE), f=gl(2, 10)) ( p = qplot(x, data=d, position="dodge", fill=f) + scale_fill_grey() ) library(gridExtra) grid.arrange(p, p, p , p, ncol=2) HTH, baptiste
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.
______________________________________________ R-help at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.