Friday, 3 August 2012

Making R graphics legible in presentation slides | Civil Statistician

Excellent tips here from 

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

one of the comments also pointed out a little-known directlabels package, you don't even have to position (or colour) the labels manually. The package works with both ggplot2 and lattice graphics, supports several different graph types, and is extremely easy to use. Take a look at the directlabels Web site for some usage examples.

No comments:

Post a Comment

Datanami, Woe be me