Tips, Tricks, and Resources to
Elevate Your Dataviz
DataLab | 18th November 2024
👩 Cara Thompson
👩💻 Love for patterns in music & language, and a fascination with the human brain |>
Psychology PhD |>
Analysis of postgraduate medical examinations |>
Data Visualisation Consultant
💙 Helping others maximise the impact of their expertise
👩 Cara Thompson
👩💻 Love for patterns in music & language, and a fascination with the human brain |>
🥐 🥣 |
🎸 🎹 🎶 |
🎨 👩🎨
Psychology PhD |>
🧠 |
🎹 💬 💥 ✨
Analysis of postgraduate medical examinations |>
👩⚕️ 😨 👨⚕️ |
📈 💡
Data Visualisation Consultant
💙 Helping others maximise the impact of their expertise
👩 Cara Thompson
👩💻 Love for patterns in music & language, and a fascination with the human brain |>
Psychology PhD |>
Analysis of postgraduate medical examinations |>
if (year %in% c(2019, 2021)) {
family <- family +
👶
} |>
Data Visualisation Consultant
💙 Helping others maximise the impact of their expertise
{ggplot2}
+ a few othersI’m planning an expedition to the islands where the Palmer Penguins live. I need to see at least 2 penguin species on my trip, but I can only go to one island.
I’m terrified of penguins with long beaks.
Help me plan my trip. You can only show me one slide.
“We have collected data about 344 penguins who live on Biscoe, Dream and Torgersen. On Biscoe, we have 44 Adelie penguins (F = 22, M = 22) and 124 Gentoos (F = 58, M = 61, Unknown = 5). On Dream, we have 56 Adelie penguins (F = 27, M = 28, Unknown = 1) and 68 Chinstrap penguins (M = F = 34). On Torgersen, we only have Adelies (F = 24, M = 23, Unknown = 5).
The average beak lengths of the species are as follows:
Have a nice trip!”
“Does this help?”
“Ok, let me reorganise it a bit”
“Look, the data really speaks for itself… Here you go!”
X Timestamp month year Value city
1 1 Jun 2014 Jun 2014 67.4 Edinburgh
2 2 Jul 2014 Jul 2014 35.2 Edinburgh
3 3 Aug 2014 Aug 2014 90.0 Edinburgh
4 4 Sep 2014 Sep 2014 20.6 Edinburgh
5 5 Oct 2014 Oct 2014 92.4 Edinburgh
6 6 Nov 2014 Nov 2014 9.8 Edinburgh
7 7 Dec 2014 Dec 2014 51.4 Edinburgh
8 8 Jan 2015 Jan 2015 50.2 Edinburgh
9 9 Feb 2015 Feb 2015 27.2 Edinburgh
10 10 Mar 2015 Mar 2015 51.2 Edinburgh
X Timestamp month year Value city
229 229 Jul 2023 Jul 2023 120.0 Glasgow
230 230 Aug 2023 Aug 2023 58.6 Glasgow
231 231 Sep 2023 Sep 2023 113.8 Glasgow
232 232 Oct 2023 Oct 2023 101.8 Glasgow
233 233 Nov 2023 Nov 2023 77.0 Glasgow
234 234 Dec 2023 Dec 2023 151.4 Glasgow
235 235 Jan 2024 Jan 2024 111.0 Glasgow
236 236 Feb 2024 Feb 2024 73.6 Glasgow
237 237 Mar 2024 Mar 2024 78.0 Glasgow
238 238 Apr 2024 Apr 2024 94.6 Glasgow
“Give me a graph of mean monthly rainfall in Glasgow and Edinburgh”
Should the bars be stacked?
Should the bars be stacked?
Wait a minute, should these be bars in the first place?
“It always rains more in Glasgow, you’re right!”
“Gosh, Edinburgh has really ‘hit and miss’ summers!”
https://datavizcatalogue.com/
Let’s avoid the bars!
Make it easier to distinguish between the cities
Make the grid more useful
Make the axis text more useful
See if we can remove any text
See if you can remove any text
We probably need to give it some context…
Make the y axis clearer
Now, let’s see what else we can do…
Find out more: cararthompson.com/talks/nhsr2022-palatable-palettes/
Glasgow and Edinburgh
Glasgow and Edinburgh
What about the order?
Glasgow and Edinburgh
Glasgow and Edinburgh over the years
Glasgow and Edinburgh over the years
cararthompson.shinyapps.io/monochromeR
#2c3d4f
)cararthompson.shinyapps.io/monochromeR
#2c3d4f
)So much more than red and green - vis4.net/palettes
Starting point
Starting point
Make the text fit - the easy way!
Let’s add some personality
Let’s add some personality
Let’s add some hierarchy
Let’s add some hierarchy
Let’s add some hierarchy
Let’s add some hierarchy
Let’s add some hierarchy
Let’s add some hierarchy
Let’s add some hierarchy
Find out more: Ten tips for better text
Starting point
Nicer grid colour
Add a background colour?
Give everything some space to breathe
Declutter, declutter, declutter
On-brand, accessible colour palettes (incl. text, gridlines and backgrounds)
“Wow, I love it!! Thank you so much, this is so helpful - it takes a huge weight off my shoulders and will save me an incredible amount of time.”
Bespoke dataviz design system packages | basic_plot
Find out more: cararthompson.com/services#dataviz-design-systems
Bespoke dataviz design system packages | basic_plot + theme_ophelia() + scale_colour_ophelia()
Find out more: cararthompson.com/services#dataviz-design-systems
Starting point
Add the mean monthly rainfall
Hello {geomtextpath}
!
Style the label
Adjust the position of the label
Add the UK mean for comparison…
Highlight interesting observations
Highlight interesting observations
Highlight interesting observations
Highlight interesting observations
Highlight interesting observations
Highlight interesting observations
Find out more: cararthompson.com/talks/shiny-dynamic-annotations
Place legend within the title
Find out more: cararthompson.com/talks/shiny-dynamic-annotations
Our plot…
rain_data |>
ggplot() +
geom_jitter(
aes(x = dplyr::case_when(city == "Glasgow" ~ as.numeric(month) - 0.1,
TRUE ~ as.numeric(month) + 0.1),
y = Value,
colour = city,
alpha = year),
size = 5,
width = 0.05,
height = 0) +
labs(title = "Rainfall in <span style='color:#4f3c78'>Glasgow</span> and <span style='color:#7691b1'>Edinburgh</span> over the years",
subtitle = "Each dot represents the total rainfall within a given month from 2014 to 2024. The more faded the dot, the further ago the year it represents.") +
scale_alpha(range = c(0.3, 1)) +
scale_x_continuous(breaks = c(1:12), minor_breaks = NULL,
labels = month.abb[1:12]) +
scale_colour_manual(values = c("Glasgow" = "#4f3c78",
"Edinburgh" = "#7691b1")) +
theme_minimal() +
theme(axis.title = element_blank(),
legend.position = "none") +
ophelia::theme_ophelia() +
theme(text = element_text(family = "Nunito Sans",
colour = "#2B2529"),
axis.title = element_blank(),
legend.position = "none",
plot.title = element_text(family = "Crimson Pro",
face = "bold",
colour = "#10090E",
size = rel(1.6)),
plot.subtitle = ggtext::element_textbox_simple(
size = ggplot2::rel(1.2),
lineheight = 1.3,
margin = ggplot2::margin(10, 0, 20, 0,
unit = "points")),
panel.grid = element_line(colour = "#F1F1F2"),
panel.grid.major.x = element_blank(),
plot.background = element_rect(colour = "#FEFCF7",
fill = "#FEFCF7"),
plot.margin = ggplot2::margin(20, 30, 20, 30,
unit = "points"))
Hello, {ggiraph}
!
rain_data |>
ggplot() +
ggiraph::geom_jitter_interactive(
aes(x = dplyr::case_when(city == "Glasgow" ~ as.numeric(month) - 0.1,
TRUE ~ as.numeric(month) + 0.1),
y = Value,
colour = city,
alpha = year),
size = 5,
width = 0.05,
height = 0) +
labs(title = "Rainfall in <span style='color:#4f3c78'>Glasgow</span> and <span style='color:#7691b1'>Edinburgh</span> over the years",
subtitle = "Each dot represents the total rainfall within a given month from 2014 to 2024. The more faded the dot, the further ago the year it represents.") +
scale_alpha(range = c(0.3, 1)) +
scale_x_continuous(breaks = c(1:12), minor_breaks = NULL,
labels = month.abb[1:12]) +
scale_colour_manual(values = c("Glasgow" = "#4f3c78",
"Edinburgh" = "#7691b1")) +
theme_minimal() +
theme(axis.title = element_blank(),
legend.position = "none") +
ophelia::theme_ophelia() +
theme(text = element_text(family = "Nunito Sans",
colour = "#2B2529"),
axis.title = element_blank(),
legend.position = "none",
plot.title = element_text(family = "Crimson Pro",
face = "bold",
colour = "#10090E",
size = rel(1.6)),
plot.subtitle = ggtext::element_textbox_simple(
size = ggplot2::rel(1.2),
lineheight = 1.3,
margin = ggplot2::margin(10, 0, 20, 0,
unit = "points")),
panel.grid = element_line(colour = "#F1F1F2"),
panel.grid.major.x = element_blank(),
plot.background = element_rect(colour = "#FEFCF7",
fill = "#FEFCF7"),
plot.margin = ggplot2::margin(20, 30, 20, 30,
unit = "points"))
ggiraph::girafe(ggobj = interactive_version)
Hello, {ggiraph}
!
Style the tooltip…
hello@cararthompson.com
cararthompson.com/talks
What would be missing if this visualisation wasn’t included? How would you tell this story to someone over coffee? How can you replicate that story in the way you present the information?
What do your colours represent? Do they look nice together? Do you need to tweak them so that they look “on brand”?
Is enough of dark-to-light variation between your colours? Have you used slightly blended colours? Have you run them through an colourblindness simulator?
What kind of personality do you want to convey through the font? Have you checked it is legible in small print for all users? Have you checked the contrast between the text colour and the background colour?
Curate a set of data visualisation types that you know your users find helpful. If you are looking to automate your colours and fonts, there are a few tools at your disposal.
hello@cararthompson.com
cararthompson.com/talks