Presentation ready plots

Lecture 11

Dr. Mine Çetinkaya-Rundel

Duke University
STA 313 - Spring 2023

Warm up

Announcements I

Presentations tomorrow in lab:

  • Bring a laptop to fill out feedback forms

  • One more team evaluation to be filled out promptly after class

  • Presentation order to be announced in class tomorrow

We might go over by 10 mins max for each lab section. Let me know if this presents a big issue for getting to your next class.

Announcements II

  • Guest lecture on Thursday – make sure to complete the reading before class

  • Take note of Project 2 presentation date: must be in class in person to present or present live via Zoom in case of isolation

  • New teams to be announced next week

Setup

# load packages
library(countdown)
library(tidyverse)
library(ggrepel)
library(patchwork)

# set theme for ggplot2
ggplot2::theme_set(ggplot2::theme_minimal(base_size = 14))

# no plot sizing defaults for this slide deck

Telling a story

Multiple ways of telling a story

  • Sequential plots: Motivation, then resolution

  • A single plot: Resolution, and hidden in it motivation

Project note: you’re asked to create two plots per question. One possible approach: Start with a plot showing the raw data, and show derived quantities (e.g. percent increases, averages, coefficients of fitted models) in the subsequent plot.

Simplicity vs. complexity

When you’re trying to show too much data at once you may end up not showing anything.

  • Never assume your audience can rapidly process complex visual displays

  • Don’t add variables to your plot that are tangential to your story

  • Don’t jump straight to a highly complex figure; first show an easily digestible subset (e.g., show one facet first)

  • Aim for memorable, but clear

Project note: Make sure to leave time to iterate on your plots after you practice your presentation. If certain plots are getting too wordy to explain, take time to simplify them!

Consistency vs. repetitiveness

Be consistent but don’t be repetitive.

  • Use consistent features throughout plots (e.g., same color represents same level on all plots)

  • Aim to use a different type of visualization for each distinct analysis

Designing effective visualizations

Keep it simple

Judging relative area

Use color to draw attention



Tell a story

Leave out non-story details

Order matters

Clearly indicate missing data

Reduce cognitive load

Use descriptive titles

Annotate figures

Project workflow overview

First, some AInspiration



Visualize the data at [url] using ggplot2.

Demo

ae-10

  • Rendering individual documents
  • Write-up:
    • Cross referencing
    • Citations
  • Presentation:
    • Pauses
    • Smaller text
  • Website: https://vizdata-s23.github.io/ae-10-YOUR_GITHUB_NAME/
    • Rendering site
    • Making sure your website reflects your latest changes
    • Customizing the look of your website.

Plot layout

Sample plots

p_hist <- ggplot(mtcars, aes(x = mpg)) +
  geom_histogram(binwidth = 2)
p_box <- ggplot(mtcars, aes(x = factor(vs), y = mpg)) +
  geom_boxplot()
p_scatter <- ggplot(mtcars, aes(x = disp, y = mpg)) +
  geom_point()
p_text <- mtcars |>
  rownames_to_column() |>
  ggplot(aes(x = disp, y = mpg)) +
  geom_text_repel(aes(label = rowname)) +
  coord_cartesian(clip = "off")

Slide with single plot, little text

The plot will fill the empty space in the slide.

p_hist

Slide with single plot, lots of text

  • If there is more text on the slide

  • The plot will shrink

  • To make room for the text

p_hist

Small fig-width

For a zoomed-in look

```{r}
#| fig-width: 3
#| fig-asp: 0.618

p_hist
```

Large fig-width

For a zoomed-out look

```{r}
#| fig-width: 10
#| fig-asp: 0.618

p_hist
```

fig-width affects text size

Multiple plots on a slide

First, ask yourself, must you include multiple plots on a slide? For example, is your narrative about comparing results from two plots?

  • If no, then don’t! Move the second plot to to the next slide!

  • If yes,

    • Insert columns using the Insert anything tool

    • Use layout-ncol chunk option

    • Use the patchwork package

    • Possibly, use pivoting to reshape your data and then use facets

Columns

Insert > Slide Columns

Quarto will automatically resize your plots to fit side-by-side.

layout-ncol

```{r}
#| fig-width: 5
#| fig-asp: 0.618
#| layout-ncol: 2

p_hist
p_scatter
```

patchwork

```{r}
#| fig-width: 7
#| fig-asp: 0.4

p_hist + p_scatter
```

patchwork layout I

(p_hist + p_box) /
  (p_scatter + p_text)

patchwork layout II

p_text / (p_hist + p_box + p_scatter)

patchwork layout III

p_text + p_hist + p_box + p_scatter + 
  plot_annotation(title = "mtcars", tag_levels = c("A"))

patchwork layout IV

p_text + {
  p_hist + {
    p_box + p_scatter + plot_layout(ncol = 1) + plot_layout(tag_level = 'new')
  }
} + 
  plot_layout(ncol = 1) +
  plot_annotation(tag_levels = c("1","a"), tag_prefix = "Fig ")

More patchwork


Learn more at https://patchwork.data-imaginist.com.

Want to replicate something you saw in my slides?


Look into the source code at https://github.com/vizdata-s23/website/slides.