Re: [R] black and white in qplot? layout 4 graphs in one screen
You might find the ggplot mailing list a friendlier place to ask questions about ggplot2. Hadley On Wed, Dec 21, 2011 at 2:16 PM, rachaelohde cox.rach...@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? 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@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. -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/ __ R-help@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.
Re: [R] black and white in qplot? layout 4 graphs in one screen
Hi, On 22 December 2011 09:16, rachaelohde cox.rach...@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@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. __ R-help@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.
[R] black and white in qplot? layout 4 graphs in one screen
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. __ R-help@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.
Re: [R] black and white in qplot? layout 4 graphs in one screen
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@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. __ R-help@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.