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

Uwe Ligges ligges at statistik.tu-dortmund.de
Thu Dec 22 09:45:38 CET 2011



On 21.12.2011 21:16, rachaelohde 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?
>
> 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?

What is ddply and what is qplot?
If you find that out for yourself, please also tell on the list where 
you took those functions from. qplot is not on base R graphics, hence 
see the help page of the package you took that function from (assuming 
ggplot2).

Uwe Ligges





>
> 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.



More information about the R-help mailing list