A recent conversation on Twitter reminded me of a powerful way to edit graphs created in R inside PowerPoint:
@dbkell @gepasi actually really powerful: save as emf from #rstats, ungroup in ppt, can then edit every single part of graph
— Mick Watson (@BioMickWatson) January 5, 2015
I realise that R is incredibly powerful anyway, and that much of this can be done within R, but I am also painfully well aware that R is hard, and that many users prefer “point-and-click”.
This example uses Windows.
1. In R, let’s create a graph:
data(iris) plot(iris$Sepal.Length, iris$Sepal.Width, main="My Graph", xlab="Width", ylab="Length")
2. You should see something like the graph below. In the top left hand corner, choose File -> Save As -> Metafile, and save it somewhere convenient
3. Now, fire up PowerPoint and start with a blank slide. Choose insert picture
Navigate to the .emf file you just saved and choose it. You should see:
4. Now, right click the image, choose group -> ungroup:
You will get a message asking if you want to convert the image to a Microsoft Drawing object. Choose yes:
5. Now repeat step 4. Right click the image, choose group -> ungroup:
You should now see something like this:
Every single part of the graph is now selectable, moveable and editable! Click outside of the chart area to de-select everything, and then click on individual components to edit them. In the graph below I have changed the title, and given one of the data points a red background:
Enjoy!
(I realise there are other ways to do this, perhaps better ways e.g. export as PDF then edit in Illustrator (thanks @bioinformagic)! This post is really aimed at those familiar and comfortable with PowerPoint :-))