Your Feedback Helps Shape The Module

Please take a few minutes to complete the Student Voice section on NOW.

  • Tell us what supports your learning and what could work better.
  • Your feedback helps us decide what to change and what to keep for future cohorts.
  • More responses give us a better picture of the whole class experience, not just a few voices.
  • Even without detailed comments, your response counts.

Your feedback is anonymous, valued, and used: we read and consider every comment and act on feedback to improve teaching and learning.

Weeks 2 To 5 Build One Workflow

  • Week 2: Principles of data visualisation
  • Week 3: Grammar of graphics; aesthetics and attributes
  • Week 4: Major visualisation tools
  • Week 5: Customising visualisations (scales, themes, and labels)

Customising visualisations

By the end of this session, you should be able to:

  1. Improve ggplot2 visualisations using labels, legends, colour, and simple themes.
  2. Choose aesthetics and scales that fit the variable type and comparison.
  3. Decide which customisation improves clarity, and which is only decoration.
  4. Start a formative assessment RMarkdown using either the provided dataset or your own dataset.

Download the Week 5 files from NOW. Unzip the folder, then move the unzipped Week 5 folder into your existing RStudio Project folder.

Today: Practical Scope

The session has two practical blocks.

Block Main work Files
1 Make plots easier to understand with labels, legends, colour, and aesthetics. 01_labels_and_legends.Rmd
02_colours_and_aesthetics.Rmd selected parts
2 Start a formative assessment figure and decide what the plot should show. 04_formative_practice_provided_data.Rmd
or 05_formative_planning_own_data.Rmd

03_themes.Rmd is optional/homework/reference material for after the session.

The priority today is not to try every customisation option. It is to make better decisions about which changes help the viewer.

Discussion: What Helps You Read This Chart?

Every Element Should Help Readers Understand The Data

Revisiting Week 2: Tufte’s principles (Tufte, 2001).

  • Data-ink ratio: make the data marks more prominent than the supporting marks.
  • Chartjunk: remove decoration that does not help the comparison.
  • Small multiples: use consistent scales and layouts so groups can be compared fairly.
  • Narrative graphics: use text, annotations, and labels to guide interpretation.

Plot don’t have to be minimal. But, every customisation should earn its place.

Tufte Ideas Become ggplot2 Decisions

In ggplot2, these principles become specific choices we can make and justify.

Tufte principle ggplot2 decision
increase data-ink use quiet themes, lighter grids, and visible data marks
reduce chartjunk avoid decorative palettes, heavy backgrounds, and unnecessary legends
support comparison with small multiples use facets, consistent scales, and aligned axes
guide interpretation write meaningful titles, axis labels, legend labels, and captions
avoid distortion choose sensible scales, transparency, jittering, or grouping aesthetics

The grammar of graphics helps because each layer can be changed deliberately: data, mapping, geom, scale, coordinate system, facet, and theme.

Customisation Serves The Comparison

Customisation should help the viewer answer the question.

Customisation Helps the viewer… Ask yourself…
labels know what the variables, units, and groups mean could this plot stand alone in a report?
legends and facets understand which observations belong to which group are the group names meaningful?
colour and aesthetics compare categories, ordered values, or continuous values does the aesthetic fit the variable type?
scales read values fairly and accurately could the scale mislead the comparison?
themes remove unnecessary distraction did this remove clutter or add decoration?
figure size and scaling read the figure at its final size are text, points, and proportions still clear?

Scaling down shrinks text and points too. Check relative sizes in the knitted report.

Labels Make Plots Stand Alone

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() + 
  labs()

Titles Could Name The Comparison

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() + 
  labs(
    title = "Reaction time and duration")

Subtitles Add Context

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() + 
  labs(
    title = "Reaction time and duration",
    subtitle = "Participant-level averages")

Captions Tell Readers Where Data Came From

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) +
  geom_point() + 
  labs(caption = "Data: picture naming norms")

Tags Can Label Panels

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) +
  geom_point() + 
  labs(tag = "A")

Axis Labels Need Units

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) +
  geom_point() + 
  labs(x = "Production duration (ms)",
       y = "Reaction time (ms)")

Legend Titles Name The Grouping

  • title
  • subtitle
  • caption
  • tag
  • x
  • y
  • colour, shape, linetype, fill
ggplot(d_spellname, aes(y = rt,
    x = dur,
    colour = modality)) +
  geom_point() + 
  labs(colour = "Response mode")

Exercise 1: Changing Text (about 12 minutes)

Open 01_labels_and_legends.Rmd.

Write axis labels, improve legend titles and group labels, and label combined colour/shape legends.

Keep one labelled figure and one sentence explaining your choice.

Further label examples are marked optional; you are welcome to continue.

Variable Type Also Guides Aesthetics

In Week 4, variable type helped us choose geoms. Today, it helps us choose aesthetics and scales.

Variable type Good aesthetic choices Be careful with
categorical groups colour, fill, shape, linetype, facets too many colours or shapes
ordered categories ordered colour, position, facets unordered palettes
continuous values position, colour gradient, size size can be hard to compare

A binary variable has two categories; it does not need a separate set of aesthetics.

A redundant legend repeats information already clear elsewhere: for example, a boxplot’s x-axis names each group, and its fill legend repeats those same groups. Colour and shape together can still help accessibility.

Next we focus on colour: distinguishing categories versus showing ordered or continuous values.

Colour: Hue Versus Brightness

For values either side of a meaningful midpoint, use a diverging palette with a neutral centre.

Use different hues for different kinds of things. Use light-to-dark progressions for more/less.

Colour Scales Control The Palette

  • scale_colour_discrete
  • scale_colour_continuous
  • scale_colour_manual
  • or any other aesthetic instead of colour
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() +  
  scale_colour_discrete()

Continuous Colour Shows More And Less

  • The colour bar shows a progression, not separate categories.
  • scale_colour_viridis_c(): c means continuous; d means discrete.
ggplot(d_colour_age,
    aes(x = rt_hand_d,
        y = rt_hand_nd,
        colour = age)) +
  geom_point() +
  scale_colour_viridis_c()

Reverse The Scale

direction = -1 reverses the palette.

ggplot(d_colour_age,
    aes(x = rt_hand_d,
        y = rt_hand_nd,
        colour = age)) +
  geom_point() +
  scale_colour_viridis_c(
    direction = -1)

Existing Palette Functions Are The Easiest Start

  • Use a palette function first
  • ggthemes::scale_colour_colorblind()
  • Then customise manually only when needed
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() +  
  scale_colour_colorblind()

Manual Colours Should Support Comparison

  • Change colour values manually
  • Colour names: link
  • ggthemes
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() +  
  scale_colour_manual(
    values = c("#0072B2", "#D55E00"))

Store Palette Values When You Need Manual Control

  • Start from a tested palette
  • Store hex codes if you need to reuse them
  • scales::show_col() previews colours
# RGB codes of "colorblind" function
mycolours <- c("#000000", "#E69F00",
               "#56B4E9", "#009E73",
               "#F0E442", "#0072B2",
               "#D55E00", "#CC79A7")

# RGB codes of "colorblind" function
scales::show_col(colorblind_pal()(8))

Legend Labels Should Be Human-Readable

  • Replace data codes with readable group names
  • labels changes the legend wording
  • values controls the corresponding colours
ggplot(d_spellname, 
       aes(y = rt,
           x = dur,
           colour = modality)) +
  geom_point() +  
  scale_colour_manual(
    labels = c("Spoken output",
               "Written output"),
    values = mycolours[1:2])

Discussion: Hue, Brightness, Shape, Or Facets?

Each version shows the same relationship. Which would you use, and what trade-off does it make?

Does brightness imply an order or make one group more prominent? When do shape or facets help?

Exercise 2: Colour And Aesthetic Decisions (about 12 minutes)

Open 02_colours_and_aesthetics.Rmd.

Choose a palette and compare overlapping age distributions.

Record which version you would use and what the viewer can compare more easily.

Further colour examples are marked optional; you are welcome to continue.

theme_grey(): Reference Structure For Exploration

The next four plots keep data, mappings, geoms, and scales fixed. Only the theme changes.

Useful context: exploratory work, when readers need to locate values and compare panels.

Why it helps: white grids provide references; the grey panel separates the data region from the margins.

Check the knitted report: are the points and lines easy to see against the background?

Add it with plot + theme_grey().

theme_bw(): Clear References On White

Useful context: reports or projection, where a white background and clear reference structure can help.

Why it helps: grids support value readings; borders clearly separate panels.

Trade-off: borders and grids add non-data ink and can compete with dense data.

Add it with plot + theme_bw().

theme_classic(): Emphasise The Overall Pattern

Useful context: showing an overall trend or distribution when precise value readings matter less.

Why it helps: removing grids reduces competing marks and emphasises the data.

Trade-off: without grids, reading values far from the axes is harder.

Add it with plot + theme_classic().

theme_minimal(): Keep Grids Without Heavy Framing

Useful context: uncluttered reports or multi-panel figures that still need grid references.

Why it helps: removes backgrounds and borders while retaining useful guides for reading values.

Trade-off: weaker panel boundaries may make separate panels less distinct.

Add it with plot + theme_minimal().

Theme features: ggplot2 documentation. Choose a theme that helps readers compare the data and remains clear in your knitted report. The simplest-looking theme is not always the clearest.

Optional/Homework: Themes

03_themes.Rmd is optional/homework/reference material.

In your own time, use it to compare themes and practise changing individual elements. Worked examples are in the separate Supplementary Materials: Customising Visualisations slide set. Detailed theme customisation is not part of today’s main practical work.

Useful Resources For Data Visualisation

Recommended Reading

Start The Formative Figure

Use one of the two templates in the Week 5 files:

  • 04_formative_practice_provided_data.Rmd if you want to practise with the provided Blomkvist dataset.
  • 05_formative_planning_own_data.Rmd if you already have a candidate dataset.

Start by deciding what your first figure should help the viewer compare.

Use the next 25 minutes to:

  • Choose one question and draft one figure.
  • Give the document a title about your data or question.
  • Give the figure section a heading about the comparison.
  • Add a caption and explain one design choice in 2-3 sentences.

You can run chunks while developing the figure.

Formative Assessment: The Full Brief

Select a behavioural dataset, such as reaction times, survey responses, or decision-making data.

  • Create 3-4 visualisations using different techniques (e.g., boxplot, scatterplot, density plot).
  • Include brief commentary on:
    • What each visualisation highlights about the data?
    • Why each visualisation was chosen?
    • How each visualisation adheres to principles of effective visualisation (e.g., Tufte’s guidelines)?
    • What each visualisation may obscure about the data.
  • Deadline: Friday 30 October 2026, before 2 pm
  • Length: max 1,000 words

Feedback focus:

  • Clarity and effectiveness of visualisations.
  • Code quality and reproducibility.
  • Interpretation and communication of behavioural insights.

Submit Files Needed To Reproduce Your Work

Submit one ZIP archive, keeping the project folder structure intact.

Include What it provides
R Markdown (.Rmd) your code and commentary
Rendered report (.html) your finished figures and text
RStudio project (.Rproj) the project starting point
Data files used by the code the inputs needed to recreate the figures
Supporting files e.g., references.bib, apa.csl, images, helper scripts
GenAI Usage Declaration Form the required declaration

Check: unzip into a new folder, open the project, restart R, and knit the report. Use relative paths, not paths to your own computer. Keep the submission anonymous.

Explain The Choice In Your Own Figure

Choose one or two decisions in your figure. Explain how they help answer your question and what the figure still hides.

Decision Options you could compare
Showing variation raw points, a summary, or both
Distinguishing groups colour, colour and shape, or separate facets
Showing overlap opaque fill, transparent fill, or outlines
Making text useful variable names or descriptive labels with units; a question or finding as the title
Keeping useful structure keep, lighten, or remove grid lines; choose a starting theme

Example: “I used transparent fills so the overlapping age distributions remain visible, but the curves do not show how many participants are in each group.”

Before Week 6: Install Shiny

Next week we will start building interactive apps in R. Install Shiny before the session so we can spend class time working with the apps.

Run this once in RStudio; skip it if Shiny is already installed:

install.packages("shiny")

Then check that the package loads:

library(shiny)

If this runs without an error, you are ready. Let me know before the session if installation does not work.

References

Andrews, M. (2021). Doing data science in R: An introduction for Social Scientists. SAGE Publications Ltd.

Tufte, E. R. (2001). The visual display of quantitative information (2nd ed.). Graphics Press.