Making R graphics legible in presentation slides
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.
I only visited a few JSM sessions today, as I’ve been focused on preparing for my own talk tomorrow morning. However, I went to several talks in a row which all had a common problem that made me cringe: graphics where the fonts (titles, axes, labels) are too small to read.
Dear colleagues: if we’re going to the effort of analyzing our data carefully, and creating a lovely graph in R or otherwise to convey our results in a slideshow, let’s PLEASE save our graphs in a way that the text is legible on the slides! If the audience has to strain to read your graphics, it’s no easier to digest than a slide with dense equations or massive tables of numbers.
For those of us working in R, here are some very quick suggestions that would help me focus on the content of your graphics, not on how hard I’m squinting to read them.
- Instead of clicking “Save as” or “Copy to clipboard” to get your graph into your slides, use functions like
png
orpdf
to save it to a file. This gives you more control over the image height and width in pixels or inches, as well as over the point size for text in the image. For example,png("mygraph.png", pointsize=18)
should do nicely. (Usepdf
instead if you’re working with Beamer and LaTeX.) Remember to callpng
, then the commands for making your plot, then calldev.off()
at the end so R knows you’re done plotting. - While we’re at it, consider whether you really need a legend for your scatterplots or line plots. If your lines or your point-clusters are well separated, it’ll be much easier to read the graph if you just put labels next to each line or cluster, rather than forcing readers’ eyes to keep jumping from the main graph to the legend and back.
- Finally, take a few seconds to choose a colorblind-safe palette. Red-green colorblindness is common enough, but unfortunately R’s first color defaults (after black) are red and green… Use the
RColorBrewer
package’s Dark2 palette, or check out other options on the Color Brewer website.
If any of that’s unclear, here’s a quick example, using the trusty old iris data:
# Set up a colorblind-safe palette with three colors library(RColorBrewer) iriscolors = brewer.pal(3, "Dark2") # Find the means of each cluster irismeans = aggregate(iris[3:4], by=iris[5], FUN=mean) # Create the plot with a larger point size png("LegibleGood.png", pointsize=18) # Use pch=20 so dots are filled, not hollow plot(iris[3:4], col=iriscolors[unclass(iris$Species)], main="Iris Data", pch=20) # Label the clusters near their means # (adjusted manually so labels do not overlap points) text(irismeans[,2]+c(1,1,-1), irismeans[,3]+c(0,-.2,.2), irismeans[,1]) dev.off()
Let me know if there’s anything unclear in the example above, or if you have a better way to do this or any other advice to offer.
For more suggestions on preparing good presentations, see also:
- Cosma Shalizi’s guidance on academic talks
- Clay Johnson’s advice on preparing for a talk
- the American Statistical Association’s guidelines for effective presentations
- Dianne Cook and Rob Hyndman‘s advice for useR conference talks
R-bloggers.com offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.