Making R graphics legible in presentation slides

[This article was first published on Civil Statistician » R, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
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.

You used R's default settings when putting this graph in your slides? Too bad I won't be able to read it from anywhere but the front of the room.

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 or pdf 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. (Use pdf instead if you’re working with Beamer and LaTeX.) Remember to call png, then the commands for making your plot, then call 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:

Bigger text, labels instead of legends, and colorblind-safe color choices: much easier to read in a big presentation room.

# Set up a colorblind-safe palette with three colors
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),

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:

To leave a comment for the author, please follow the link and comment on their blog: Civil Statistician » R. 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.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)