Hello R Help! I would like to make a legible boxplot of tree growth rates for each of seven tree species at each of seven different sites. It's a lot of data to put on one figure, I know. I made a beautiful, interpretable figure using color, but my target journal can't deal with color figures. I can use seven shades of grey to fill the boxes, but the figure then becomes uninterpretable - the colors of adjacent boxes are too similar. I cannot figure out how to add a pattern, hatching, or cross-hatching to the boxes. I see that in 2003 Professor Ripley confirmed that one cannot hatch boxplots: http://tolstoy.newcastle.edu.au/R/help/03a/2622.html Is this still true? If so, does anyone have a suggestion for how to make this figure interpretable in black and white? Should I pick a different target journal? Many thanks, Gabe Functional code to make the color figure with fake data follows: # leg.txt = c("Abies grandis","Acer macrophyllum","Calocedrus decurrens","Pinus ponderosa","Pseudotsuga meziensii","Quercus garryana","Quercus kelloggii") site.txt = c("Brownsville","Chip Ross","Finley","Jim's Creek","Lowell","Mount Pisgah","South Eugene") colors = c("gray","red","white","blue","yellow","purple","orange") # Fake data here: site = rep(site.txt, each = 21) sp = rep(rep(leg.txt, each = 3), times = 7) ga = runif(147, 0, 20) datnew.lo = data.frame(site,sp,ga) # Now make the plot: boxplot(ga~sp*site,data=datnew.lo, range = 1, col = colors, ylim = c(0,30), xaxt = "n", xlab = "Site", ylab = "Basal Area Growth Increment", main = "Basal Area Growth Increment by Site and Species") axis(1, at = c(4,11,18,25,32,39,46), labels = site.txt, ) abline(v = 7.5, lty = 3) abline(v = 14.5, lty = 3) abline(v = 21.5, lty = 3) abline(v = 28.5, lty = 3) abline(v = 35.5, lty = 3) abline(v = 42.5, lty = 3) legend("topright", legend = leg.txt, fill = colors, bg = "white") [[alternative HTML version deleted]]
On Thu, Mar 8, 2012 at 1:08 PM, Gabriel Yospin <yosping at gmail.com> wrote:> Hello R Help!Hello Gabe Yospin! (I feel like I should start playing some arena rock anthem now ;-) )> > I would like to make a legible boxplot of tree growth rates for each of > seven tree species at each of seven different sites. It's a lot of data to > put on one figure, I know. I made a beautiful, interpretable figure using > color, but my target journal can't deal with color figures. I can use seven > shades of grey to fill the boxes, but the figure then becomes > uninterpretable - the colors of adjacent boxes are too similar. I cannot > figure out how to add a pattern, hatching, or cross-hatching to the boxes. > > I see that in 2003 Professor Ripley confirmed that one cannot hatch > boxplots: > > http://tolstoy.newcastle.edu.au/R/help/03a/2622.html > > Is this still true? If so, does anyone have a suggestion for how to make > this figure interpretable in black and white? Should I pick a different > target journal? >I don't think you'd need to change journals just for graphical styles: do it for much less important things, like impact factor. It sounds like the idea of small multiples might help here: I'm not a lattice pro, but here's something you could do in ggplot2 (and I know it's doable in lattice as well): I'm gonna put new lines in all your species names since space will be at a premium: levels(datnew.lo$sp) <- gsub(" ", "\n", levels(datnew.lo$sp)) library(ggplot2) ggplot(datnew.lo, aes(x = sp, y = ga)) + geom_boxplot() + facet_wrap(~site, nrow = 2) + opts(axis.text.x=theme_text(angle=45, size = 7)) Others with more ggplot / lattice - fu than I can help you tweak this but hopefully this is a start. Michael> Many thanks, > > Gabe > > Functional code to make the color figure with fake data follows: > # > leg.txt = c("Abies grandis","Acer macrophyllum","Calocedrus > decurrens","Pinus ponderosa","Pseudotsuga meziensii","Quercus > garryana","Quercus kelloggii") > site.txt = c("Brownsville","Chip Ross","Finley","Jim's > Creek","Lowell","Mount Pisgah","South Eugene") > colors = c("gray","red","white","blue","yellow","purple","orange") > # Fake data here: > site = rep(site.txt, each = 21) > sp = rep(rep(leg.txt, each = 3), times = 7) > ga = runif(147, 0, 20) > datnew.lo = data.frame(site,sp,ga) > # Now make the plot: > boxplot(ga~sp*site,data=datnew.lo, range = 1, > ? ? ? ?col = colors, > ? ? ? ?ylim = c(0,30), > ? ? ? ?xaxt = "n", > ? ? ? ?xlab = "Site", > ? ? ? ?ylab = "Basal Area Growth Increment", > ? ? ? ?main = "Basal Area Growth Increment by Site and Species") > axis(1, at = c(4,11,18,25,32,39,46), > ? ? labels = site.txt, > ? ? ) > abline(v = 7.5, lty = 3) > abline(v = 14.5, lty = 3) > abline(v = 21.5, lty = 3) > abline(v = 28.5, lty = 3) > abline(v = 35.5, lty = 3) > abline(v = 42.5, lty = 3) > legend("topright", legend = leg.txt, fill = colors, bg = "white")Thanks for the great reproducible example! Made this much easier and more fun.> > ? ? ? ?[[alternative HTML version deleted]] > > ______________________________________________ > 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.
On 3/8/2012 1:08 PM, Gabriel Yospin wrote:> I would like to make a legible boxplot of tree growth rates for each of > seven tree species at each of seven different sites. It's a lot of data to > put on one figure, I know. I made a beautiful, interpretable figure using > color, but my target journal can't deal with color figures. I can use seven > shades of grey to fill the boxes, but the figure then becomesIf you print your original figure (with the legend) in B/W, you'll see that the shading levels are not too bad -- they are relatively distinguishable except for Acer and Pinus/ Thus, one thing I often do in this situation is design a graph so that it will render reasonably well also in B/W and suggest to the journal to make a color version available online (or I put it on my own web). Your final version using ggplot2 is a far worse graph, IMHO because the labels are illegible, and using no fill in the boxplots makes it impossible to distinguish the same species across sites. You could make it better by (a) only labeling the species in alternate site panels (b) rotating those labels by 45^o (c) using some fill for the boxes My .05 -- Michael Friendly Email: friendly AT yorku DOT ca Professor, Psychology Dept. York University Voice: 416 736-5115 x66249 Fax: 416 736-5814 4700 Keele Street Web: http://www.datavis.ca Toronto, ONT M3J 1P3 CANADA
Apparently Analagous Threads
- Counting the occurence of each unique "charecter string"
- Counting the occurence of each unique "charecter string"
- Can I index a dataframe with a reference from/to a second dataframe?
- censor=FALSE and id options in survfit.coxph
- Removing rows w/ smaller value from data frame