R, Tutorial

Keeping beautiful R graphs beautiful in PowerPoint

Over the past few years I have fallen in love with graphs made with R. They can be as beautiful as your imagination can make them. When converted to .pdf, thanks to vector graphics, they stay crisp at any size.

Unfortunately, it is not always easy to preserve this beauty when I want to publish these graphs or show them in professional presentations. Yes, all the glories of R graphics are preserved perfectly using knitr + Latex + Beamer + Slidify. However, I have many presentations that I have painstakingly prepared in PowerPoint. If I want to add just one new image to such a presentation, it would be very difficult to remake the whole presentation in a different format. Furthermore, almost no Psychology journals accept Latex documents.

Because I was unaware of a better solution, I have made graphics in R, converted them to .pdf, used Adobe Reader’s snapshot tool to copy the images (zoomed to 200%), and pasted the images as bitmaps in PowerPoint or Word. The images look okay but they are not truly scalable. It has been disappointing to see them lose image quality.

MS Office documents have a scalable vector format for images called enhanced metafile (.emf). R has the ability to save graphics as enhanced metafiles but the results are ugly (no anti-aliasing).

The best (free) solution I have found so far is to save graphics made in R as scalable vector graphics (.svg), open them in Inkscape (a free alternative to Adobe Illustrator), saving them as enhanced metafiles (.emf), and importing them into PowerPoint or Word. The results are (nearly) perfect! The only flaws I have identified so far is that semi-transparent colors become opaque and some lines with flat endings become lines with rounded endings. In most cases, I am very satisfied with the results.

Also, enhanced metafiles usually have extremely large file sizes when made in PowerPoint. However, when made in R the .emf file sizes have been very reasonable.