From last week to this week

Last week:

  • module overview and assessment
  • RMarkdown, code chunks, citations, and rendering to HTML
  • organising files in an RStudio Project

This week:

  • why visualisation matters for behavioural data
  • first ggplot2 plots
  • principles for clear and honest visualisation

Download psyc40940-week-02-foundations.zip from the Learning Room. Unzip it and move the Week 2 folder into your module RStudio Project folder.

Timing today

Two teaching blocks of about 50 minutes.

Block 1

  • 5 min: recap and setup
  • 10 min: data, first plots, and ggplot2 pattern
  • 25 min: Exercise 1: scatterplots
  • 10 min: why visualisation matters

Block 2

  • 10 min: Anscombe and Datasaurus
  • 15 min: Exercise 2: Datasaurus Dozen
  • 15 min: visualisation is not neutral
  • 10 min: principles, pitfalls, and wrap-up

Exercises are started in class and can be completed after the session.

The data

  • Picture naming task
  • Written and spoken responses
  • Manipulation: Prior familiarisation with most-common name for a picture
  • Outcome: response onset time
  • Data/materials: Roeser et al. (2025)

Exploring data

Rows: 8,648
Columns: 19
$ ppt_id            <dbl> 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, 40, …
$ ppt_vocab         <dbl> 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.95, 0.…
$ image_id          <chr> "almond.jpg", "ambulance.jpg", "aubergine.jpg", "austronaut.jpg", "bagpipes.jpg", "basketbal…
$ resp              <chr> "almond", "ambulance", "aubergine", "austronaut", "bagpipes", "basketball", "binoculars", "b…
$ name_familiarised <lgl> TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, …
$ modality          <chr> "speech", "speech", "speech", "speech", "speech", "speech", "speech", "speech", "speech", "s…
$ rt                <dbl> 1312, 1057, 967, 1148, 1100, 1295, 1205, 2470, 1292, 1012, 1476, 2241, 3120, 1401, 1232, 119…
$ dur               <dbl> 649, 544, 800, 680, 587, 452, 693, 618, 721, 740, 407, 873, 3510, 708, 691, 738, 287, 542, 9…
$ spell_div         <dbl> 0.52909473, 0.39199841, 1.04293875, 1.23439860, 0.88868655, 0.44764042, 1.16363177, 0.416013…
$ name_div          <dbl> 3.7269149, 0.1407271, 3.7693227, 2.9867884, 0.2224148, 0.7472810, 0.2578952, 2.8129985, 4.49…
$ aoa               <dbl> 7.67, 6.16, NA, 6.28, NA, 5.30, 6.79, 4.63, 8.72, 5.20, 9.76, 8.22, 12.25, 5.84, 9.61, 6.18,…
$ mc_resp           <chr> "almond", "ambulance", "aubergine", "astronaut", "bagpipes", "basketball", "binoculars", "bi…
$ nsyl              <dbl> 2, 3, 4, 3, 3, 3, 4, 2, 2, 3, 2, 4, 3, 2, 2, 4, 1, 3, 2, 3, 2, 1, 1, 2, 2, 3, 2, 2, 3, 3, 2,…
$ nchar             <dbl> 6, 9, 9, 9, 8, 10, 10, 7, 7, 8, 4, 10, 8, 8, 8, 11, 5, 9, 9, 10, 7, 6, 3, 7, 6, 8, 7, 7, 8, …
$ nphon             <dbl> 5, 9, NA, NA, 7, 9, 10, 6, 5, 7, 3, 10, 8, 5, 7, 8, 3, 8, 6, 8, 4, NA, 3, 5, 5, NA, 6, 6, 7,…
$ freq_sp           <dbl> 1.0769429, 4.8264469, NA, NA, 1.9932336, 2.7816910, 2.6863808, 5.5655792, 5.9289731, 3.51928…
$ freq_wr           <dbl> 4.28695376, 5.85306126, 2.35985295, 3.10592253, 3.06381104, 3.76765351, 4.76562228, 4.383414…
$ cat               <chr> "is natural", "is manmade", "is natural", NA, "is manmade", "is manmade", "is manmade", "is …
$ semcat            <dbl> -0.12349131, -0.44492604, -0.72806943, NA, 0.05315648, 0.48631844, 1.55619767, 0.33721132, 1…

Exploring data

d_ppt_pic <- distinct(d_spellname, ppt_id, image_id)
count(d_ppt_pic, ppt_id)
# A tibble: 72 × 2
   ppt_id     n
    <dbl> <int>
 1      1   141
 2      2   132
 3      3   142
 4      4   139
 5      5   136
 6      6   132
 7      7   137
 8      8   141
 9      9   142
10     10   136
# ℹ 62 more rows

What is data visualisation?

  • Using graphics to understand data
  • Using graphics to communicate evidence
  • Exploratory: what patterns are in the data?
  • Explanatory: what should the audience take away?

Common plot types:

  • scatterplots, line plots, bar plots
  • histograms, boxplots, density plots
  • pie charts, maps, heatmaps

Prepare plotting data

d_vocab <- summarise(d_spellname, 
                     rt = mean(rt),
                     .by = c(ppt_id, ppt_vocab, modality)) 
glimpse(d_vocab, width = 120)
Rows: 72
Columns: 4
$ ppt_id    <dbl> 40, 41, 42, 43, 44, 45, 46, 47, 48, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 62, 63, 64, 65, 66, …
$ ppt_vocab <dbl> 0.9500, 1.0000, 0.9250, 0.9000, 0.9750, 1.0000, 0.9250, 0.9625, 0.9750, 0.8250, 0.9375, 0.8875, 0.97…
$ modality  <chr> "speech", "speech", "speech", "speech", "speech", "speech", "speech", "speech", "speech", "speech", …
$ rt        <dbl> 1358.0756, 1273.9292, 1392.7664, 735.4684, 1188.0392, 1345.2583, 1519.9000, 1512.6337, 1479.2810, 12…

Discuss in pairs (2 mins)

What is the first thing you notice in each plot? What did you learn from it?

Building up a plot: data and aesthetics

ggplot(data = d_vocab,
       mapping = aes(x = ppt_vocab,
                     y = rt))

Building up a plot: add points

ggplot(data = d_vocab,
       mapping = aes(x = ppt_vocab,
                     y = rt)) +
  geom_point()

Building up a plot: add a trend

ggplot(data = d_vocab,
       mapping = aes(x = ppt_vocab,
                     y = rt)) +
  geom_point() +
  stat_smooth(method = "lm")

Building up a plot: add a group

ggplot(data = d_vocab,
       mapping = aes(x = ppt_vocab,
                     y = rt,
                     colour = modality)) +
  geom_point(alpha = 0.45) +
  stat_smooth(method = "lm", se = FALSE)

A more polished version

We can add labels, colour choices, and a cleaner theme later.

What to recognise today

  • data = ...: which dataset should R use?
  • aes(...): which variables go on the plot?
  • geom_point(): draw points
  • stat_smooth(): add a trend line
  • labs(): write clearer labels

Next week we will slow down and unpack the layer logic properly.

Creating an exploratory plot

20-25 minutes: Open RMarkdown document 1_scatterplots.Rmd

Aim: complete the main blanks, render the document, and write short interpretations.

Finish at home if needed.

Why data visualisation?

“[data visualization] forces us to notice what we never expected to see.” (Tukey, 1977)

  • See distributions, relationships, and outliers
  • Check whether summaries hide structure
  • Choose sensible statistical models
  • Avoid misleading conclusions

Anscombe’s quartet (Anscombe, 1973)

x
y
y ~ x
Data set Mean SD Mean SD Correlation Intercept Slope
1 9 3.32 7.5 2.03 0.82 3 0.5
2 9 3.32 7.5 2.03 0.82 3 0.5
3 9 3.32 7.5 2.03 0.82 3 0.5
4 9 3.32 7.5 2.03 0.82 3 0.5

Anscombe’s quartet

Anscombe’s quartet

The datasaurus dozen

Matejka & Fitzmaurice (2017): see link

Visualisation is not neutral

  • plots guide attention
  • summaries can hide structure
  • chart types can change interpretation
  • design choices can persuade or mislead (Pandey et al., 2014)
  • good visualisation makes comparison easier

How plots shape beliefs

Design choices influence what looks important:

  • scale: small differences can look large
  • aggregation: means can hide individuals
  • encoding: position, area, and colour are read differently
  • ordering: time, rank, and grouping imply a story
  • context: missing baselines or uncertainty change interpretation

Ask: what does this plot make easy to believe?

Pair activity: media examples

Pair activity: main points

  • Truncated y-axis: small numerical changes can look dramatic when the baseline is hidden.
  • Wrong chart type: a pie chart implies parts of one whole, so it misleads when categories overlap or add to more than 100%.
  • Election maps: large areas can look more important than densely populated areas.
  • Inverted axis: reversing the axis can make increases look like decreases.

Main point: visual design choices can change the story people see in the same data.

Same numbers, different beliefs

A bar can make the mean look like a container for the data.

Viewers can treat values inside the bar as more likely than equally distant values outside it (Correll & Gleicher, 2014).

Better alternative: show the distribution, not only the summary.

Encoding choices matter

Cleveland and McGill showed that some visual comparisons are easier than others (Cleveland & McGill, 1984).

Easier:

  • position on a common scale
  • aligned lengths

Harder:

  • angles
  • areas
  • colour intensity

Tufte’s practical test

A useful plot should help the viewer reason about the evidence.

Ask:

  • Does the plot show the data?
  • Does it make comparisons easy?
  • Does it avoid distortion?
  • Does the design support the question?

Principles of data visualisation

For this module, start with four practical questions:

  • What should the viewer compare?
  • Can they see the data, not only summaries?
  • Could the design exaggerate or hide an effect?
  • Do labels and scales reduce effort?

Principles from exploratory data analysis

Hartwig & Dearing (1979):

  • Be skeptical: every plot can mislead
  • Be open: the data may surprise you

Tufte (1983):

  • Show the data
  • Avoid distortion
  • Make comparisons easy
  • Reveal overview and detail

Same data, different design

What changes in your interpretation?

Make comparisons easy

Good plots make the intended comparison visually easy.

Use labels to reduce effort

Good labels answer:

  • What is measured?
  • What are the units?
  • What do colours or groups mean?
  • What should the viewer compare?

Principles of data visualisation

  • Show the data where possible
  • Make the intended comparison easy
  • Use scales honestly
  • Label enough for interpretation
  • Remove elements that compete with the data

Common visualisation pitfalls

Pitfall Why it matters Principle
Truncated or inverted axes changes apparent size or direction of effects avoid distortion
Overplotting hides density and individual observations show the data
Poor chart type makes the wrong comparison easy support the question
Too much decoration competes with the evidence remove non-data ink
Missing uncertainty makes estimates look more precise show variation
Weak labels or legends increases interpretation effort reduce effort

What’s wrong with these? (1)

If time: 3 minutes in pairs discuss which pitfall is most important in each example.

What’s wrong with these? (2)

If time: 3 minutes in pairs discuss which pitfall is most important in each example.

Examples: Gong & Liu (2022), Rubiah et al. (2024), Ke (2024).

Also compare the figures and open materials in van Lieburg et al. (2023): article, code and data.

Recommended Reading

Homework

Before next week:

  • complete the Week 2 visualisation exercises if you did not finish them in class
  • continue looking for a behavioural dataset for the formative assessment
  • bring dataset questions to the tutorial checkpoint on 21 October

References

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

Anscombe, F. J. (1973). Graphs in statistical analysis. The American Statistician, 27, 17–21.

Cleveland, W. S., & McGill, R. (1984). Graphical perception: Theory, experimentation, and application to the development of graphical methods. Journal of the American Statistical Association, 79(387), 531–554.

Correll, M., & Gleicher, M. (2014). Error bars considered harmful: Exploring alternate encodings for mean and error. IEEE Transactions on Visualization and Computer Graphics, 20(12), 2142–2151. https://doi.org/10.1109/TVCG.2014.2346298

Gong, R., & Liu, B. (2022). [Retracted] monitoring of sports health indicators based on wearable nanobiosensors. Advances in Materials Science and Engineering, 2022(1), 3802603. https://doi.org/https://doi.org/10.1155/2022/3802603

Hartwig, F., & Dearing, B. E. (1979). Exploratory data analysis. Sage.

Ke, Y. (2024). Examining simultaneous pausing on the cognitive writing process: A micro-formative writing assessment. Current Psychology, 43(1), 39–50.

Matejka, J., & Fitzmaurice, G. (2017). Same stats, different graphs: Generating datasets with varied appearance and identical statistics through simulated annealing. Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems, 1290–1294.

Pandey, A. V., Manivannan, A., Nov, O., Satterthwaite, M., & Bertini, E. (2014). The persuasive power of data visualization. IEEE Transactions on Visualization and Computer Graphics, 20(12), 2211–2220. https://doi.org/10.1109/TVCG.2014.2346419

Roeser, J., Aros Muñoz, P., & Torrance, M. (2025). Written picture naming norms to assess spelling difficulty. OSF. https://doi.org/10.17605/OSF.IO/JVHRZ

Rubiah, R., Degeng, I. N. S., Setyosari, P., & Kuswandi, D. (2024). The effect of problem-based learning assisted with concept mapping founded on cognitive style on the creativity of writing exposition text. Creativity Studies, 17(2), 419–434.

Tufte, E. R. (1983). The visual display of information. Graphics Press.

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

Tukey, J. W. (1977). Exploratory data analysis (Vol. 2).

van Lieburg, R., Sijyeniyo, E., Hartsuiker, R. J., & Bernolet, S. (2023). The development of abstract syntactic representations in beginning L2 learners of Dutch. Journal of Cultural Cognitive Science, 7, 289–309. https://doi.org/10.1007/s41809-023-00131-5

Wickham, H., & Grolemund, G. (2016). R for data science: Import, tidy, transform, visualize, and model data. O’Reilly Media, Inc.