Supplementary Materials: Customising Visualisations

Optional examples to explore in your own time, alongside the Week 5 theme exercise, 03_themes.Rmd.

  • Use the exercise to compare themes and practise changing individual elements.
  • Use these slides as worked examples for facet labels, axis text, legends, grids, backgrounds, and facet strips.
  • Choose changes that improve readability or comparison; you do not need to try every option.

These materials extend the main Week 5 session; detailed theme customisation is not required during class.

Facet Strips Are Labels Too

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) +
  geom_point() + 
  facet_grid(~modality)

Facet Labels Can Come From The Data

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) +
  geom_point() + 
  facet_grid(~modality,
             labeller = label_both)

Recoding Changes The Data Labels

d_spellname <- mutate(d_spellname,
  modality = recode(modality,
    speech = "Spoken output",
    writing = "Written output"))

ggplot(d_spellname, 
       aes(x = dur, 
           y = rt)) +
  geom_point() +
  facet_grid(~modality)

Strip Labels Should Match The Story

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) +
  geom_point() + 
  facet_grid(~modality, labeller = label_both)

Start From The ggplot2 Default

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  facet_grid(~modality) +
  theme_grey(base_size = 11)

theme_minimal(): No Panel Background

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  facet_grid(~modality) +
  theme_minimal(base_size = 14)

theme_light(): Light Grid And Border

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  facet_grid(~modality) +
  theme_light(base_size = 14)

theme_dark(): A Dark Panel Background

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  facet_grid(~modality) +
  theme_dark(base_size = 14)

Theme Packages Add Starting Points

ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  facet_grid(~modality) +
  theme_clean()

Choose Themes For The Comparison

  • axis
  • legend
  • panel
  • plot
  • strip
ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  theme()

Axis Text Is Part Of Readability

  • axis.text
    • axis.text.x
    • axis.text.y
  • axis.title
    • axis.title.x
    • axis.title.y
ggplot(d_spellname, 
       aes(y = rt,
           x = dur)) + 
  geom_point() +
  theme(axis.text = 
          element_text(face = "italic"))

Bold Axis Titles Can Add Emphasis

  • axis.text
    • axis.text.x
    • axis.text.y
  • axis.title
    • axis.title.x
    • axis.title.y
ggplot(d_spellname, aes(y = rt,
    x = dur)) + 
  geom_point() +
  theme(axis.title = 
          element_text(face = "bold"))

Axis Titles And Tick Labels Are Separate

  • axis.text
    • axis.text.x
    • axis.text.y
  • axis.title
    • axis.title.x
    • axis.title.y
ggplot(d_spellname, aes(y = rt,
    x = dur)) + 
  geom_point() +
  theme(axis.title.y = 
          element_text(face = "bold"))

Legends Compete For Plot Space

  • legend.background
  • legend.margin
  • legend.spacing
  • legend.key
  • legend.text
  • legend.title
  • legend.position
  • legend.orientation
  • legend.justification
  • legend.box
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) + 
  geom_point() +
  theme()

Move Legends When Space Is Tight

  • legend.background
  • legend.margin
  • legend.spacing
  • legend.key
  • legend.text
  • legend.title
  • legend.position
  • legend.orientation
  • legend.justification
  • legend.box
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) + 
  geom_point() +
  theme(legend.position = "top")

Align A Top Legend To The Right

  • legend.background
  • legend.margin
  • legend.spacing
  • legend.key
  • legend.text
  • legend.title
  • legend.position
  • legend.orientation
  • legend.justification
  • legend.box
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) + 
  geom_point() +
  theme(legend.position = "top",
        legend.justification = "right")

An Inside Legend Can Cover Data

  • legend.background
  • legend.margin
  • legend.spacing
  • legend.key
  • legend.text
  • legend.title
  • legend.position
  • legend.orientation
  • legend.justification
  • legend.box
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) +
  geom_point() + 
  theme(legend.position = c(.15, .8))

Grid Lines Can Help Or Distract

  • panel.background
  • panel.border
  • panel.spacing
  • panel.grid
    • panel.grid.major
    • panel.grid.minor
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  theme()

Remove The Panel Background

  • panel.background
  • panel.border
  • panel.spacing
  • panel.grid
    • panel.grid.major
    • panel.grid.minor
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  theme(panel.background =
        element_blank())

Plot Properties Control The Whole Figure

  • plot.background
  • plot.margin
  • plot.title
  • plot.subtitle
  • plot.caption
  • plot.tag
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() +
  theme()

A Coloured Plot Background Adds Non-Data Ink

  • plot.background
  • plot.margin
  • plot.title
  • plot.subtitle
  • plot.caption
  • plot.tag
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  theme(plot.background = element_rect(
    fill = "pink"))

Plot Margins Affect Readability

  • plot.background
  • plot.margin
  • plot.title
  • plot.subtitle
  • plot.caption
  • plot.tag
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  theme(plot.background = element_rect(
    fill = "pink"),
  plot.margin = unit(c(2, 2, 2, 2),
                     "cm"))

Title Colour Can Help Or Hinder Readability

  • plot.background
  • plot.margin
  • plot.title
  • plot.subtitle
  • plot.caption
  • plot.tag
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  labs(title = "I'm a title") +
  theme(plot.title = element_text(
    colour = "pink"))

Caption Text Can Be Styled Separately

  • plot.background
  • plot.margin
  • plot.title
  • plot.subtitle
  • plot.caption
  • plot.tag
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  labs(caption = "I'm a caption") +
  theme(plot.caption = element_text(
    face = "italic"))

Facet Strips Guide Small Multiples

  • strip.background
  • strip.placement
  • strip.text
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  facet_grid(~modality,
             labeller = label_both) +
  theme()

Strip Backgrounds Can Add Clutter

  • strip.background
  • strip.placement
  • strip.text
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  facet_grid(~modality,
             labeller = label_both) +
  theme(strip.background =
        element_blank())

Strip Background Colour Changes The Emphasis

  • strip.background
  • strip.placement
  • strip.text
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  facet_grid(~modality,
             labeller = label_both) +
  theme(strip.background = element_rect(
    fill = "forestgreen"))

Strip Text Needs To Stay Readable

  • strip.background
  • strip.placement
  • strip.text
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  facet_grid(~modality,
             labeller = label_both) +
  theme(strip.background = element_rect(fill = "forestgreen"),
        strip.text = element_text(colour = "white", hjust = 0))

Combine Theme Changes Deliberately

  • strip.background
  • strip.placement
  • strip.text
ggplot(d_spellname, aes(y = rt,
    x = dur)) +
  geom_point() + 
  facet_grid(~modality,
             labeller = label_both)+
  theme(strip.background = element_rect(fill = "forestgreen"),
        strip.text = element_text(colour = "white", hjust = 0, 
            face = "bold", size = 16, angle = 180))