Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Data Visualization in R for PPT Slides: A Simple Guide

· 5 min read · Home Tech

In this article
  1. How to Build Data Visualization Slides from R, Step by Step
  2. A Worked Example: 150 Flowers on One Slide
  3. Which R Chart Matches Which Slide Message?
  4. Where R-to-PPT Slides Usually Go Wrong
  5. Exporting Directly to a Whole R Presentation

Yes, R is one of the strongest tools for data visualization, and ggplot2 is the package to build your plots with. For a PPT, you export each chart as a high-resolution image with ggsave() and drop it into your slides, rather than pasting screenshots.

Time 8 min · Steps 8 · Level Medium

How to Build Data Visualization Slides from R, Step by Step

  1. Install and load the two packages you need. Run install.packages("ggplot2") once, then library(ggplot2) at the top of every script. ggplot2 handles the charts; the built-in datasets that ship with R give you demo data to practice on.
  2. Pick a chart type per slide, not per dataset. One slide, one message. A scatter plot shows relationships, a bar chart compares categories, a line chart shows change over time, and a box plot shows spread within groups. Choose the chart from the sentence you would say out loud about the data.
  3. Start every plot with the same three layers. Data, aesthetics, geometry: ggplot(data, aes(x = ..., y = ...)) + geom_point() for a scatter plot, + geom_bar(stat = "identity") for bars, + geom_line() for lines. Everything else is decoration on top of these three.
  4. Clean the labels before anyone sees the chart. Add labs(title = "...", x = "...", y = "...") so axes read in plain words, not variable names like "Sepal.Length". A chart in a presentation has no surrounding explanation, so the labels carry the meaning.
  5. Set text sizes for the back row. Use theme(text = element_text(size = 18)) or larger. R's default text size is tuned for a printed page, and it becomes unreadable when a slide is projected.
  6. Export with ggsave() at slide proportions. For a 16:9 slide, use ggsave("chart.png", width = 9, height = 5, dpi = 300). That gives a 2700 by 1500 pixel image, which stays sharp when projected full screen.
  7. Insert the image into PowerPoint and size it once. Use Insert > Pictures, then drag a corner handle to fit the slide. Copy that sized image's position for every later chart so all slides line up identically.
  8. Put the code on a backup slide, not the main one. Keep one appendix slide with the exact ggplot2 call behind each chart. If someone asks how a figure was made, you jump to the back of the deck and show it.

A Worked Example: 150 Flowers on One Slide

R ships with a dataset called iris: measurements of 150 flowers, 50 each from three species, with sepal length and petal width in centimetres. It is the standard practice dataset for exactly this kind of slide. The full chart takes four lines:

ggplot(iris, aes(x = Sepal.Length, y = Petal.Width, color = Species)) + geom_point(size = 3) + labs(title = "Petal width rises with sepal length", x = "Sepal length (cm)", y = "Petal width (cm)")

Then export it: ggsave("iris.png", width = 9, height = 5, dpi = 300). The result shows three visibly separated clusters of points, one colour per species, which is a complete story for a single slide: the two measurements separate the species, and the title states that finding in one sentence.

Which R Chart Matches Which Slide Message?

Match the geometry to the claim you are making, and the chart does half the talking for you. A few reliable pairings:

  • "A goes up with B" - geom_point(), one colour per group if you have one.
  • "Category X is bigger than Y" - geom_bar() with stat = "identity" and your own numbers, ordered tallest to shortest with reorder().
  • "It changed over time" - geom_line(), with the time variable on the x axis.
  • "The groups differ in spread" - geom_boxplot(), one box per group.
  • "How is this one variable distributed?" - geom_histogram(), and mention the bin width on the slide.

Reordering bars by value instead of leaving them alphabetical is the single change that most often turns a confusing bar chart into an obvious one.

Where R-to-PPT Slides Usually Go Wrong

The most common mistake is screenshotting the plot window. A screenshot captures whatever pixels happen to be on screen, so the image blurs when the slide is enlarged, and the plot window's grey background clashes with a white slide theme. ggsave() fixes both: you control the exact pixel dimensions, and theme_minimal() or theme_classic() gives you a clean white background that blends into the slide.

The second mistake is a misconception worth correcting directly: you do not need to build charts inside PowerPoint at all. R's base plot() function works, but ggplot2 is the standard for presentations because every element - colours, labels, themes - is one more line of code you can adjust and re-export in seconds. When a reviewer asks for a different colour or a renamed axis, you change one argument and re-run ggsave() instead of rebuilding the chart by hand.

Third, watch your colour choices. The default palette distinguishes groups fine on screen, but if the deck will be printed in black and white, add scale_colour_brewer(palette = "Set1") or use shapes as well as colours (aes(shape = Species) alongside colour) so the groups stay separable.

Exporting Directly to a Whole R Presentation

If you would rather skip PowerPoint entirely, R Markdown can build a slide deck natively. Create a new R Markdown presentation in RStudio (File > New File > R Markdown, then choose a presentation format; the exact labels can differ slightly by version), and each plot chunk renders straight into the slides at the right size. This suits a technical audience, because the code and the chart live in the same file and the deck regenerates whenever the data changes. For a general audience, exporting images into PowerPoint still gives you the most control over layout and narration.

One last check before you present: open the exported PNG at full screen on your own machine and read the axis labels from two metres away. If you squint, rerun the plot with a larger text size and export again - it takes about thirty seconds with the script in front of you.

Official source: The R Project for Statistical Computing