How to Vectorize Plots from R in PowerPoint

Nalina Aiempichitkijkarn
2 min readAug 28, 2024

--

Inspired by this tweet

Step 1: Create a Graph in R and Save as .svg File

# Install necessary packages if not already installed
install.packages("svglite")
install.packages("ggplot2")

# Load the ggplot2 library
library(ggplot2)

# Create a basic boxplot of Sepal Length by Species
p <- ggplot(iris, aes(x = Species, y = Sepal.Length, fill = Species)) +
geom_boxplot() +
labs(title = "Sepal Length", y = "Sepal Length", x = "Species")

# Save the plot as an SVG file
ggsave("sepal.svg", p, device = "svg")

Step 2: Open the .svg File in PowerPoint

  1. Go to InsertPicturesThis Device…, and locate the .svg file you just saved in your working directory.
  2. Right-click on the image and select Convert to Shape (or Edit Points).
  3. If needed, right-click again and choose GroupUngroup to separate the elements.
  4. Now, you can move each element, resize, and change colors individually to suit your presentation needs!

Note: In the spirit of scientific reproducibility, it’s essential to preserve the integrity of your data visualizations. Always ensure that data points remain unchanged, and group elements together when resizing or moving them.

Additionally, document any modifications made to your visualizations to avoid unintentional errors!

--

--

No responses yet