machine <- "#061939"
human <- "#e25470"
monochromeR::generate_palette(machine,
blend_colour = human,
n_colours = 3,
view_palette = TRUE)
RUG @ HDSI | September 29th, 2022
đź‘© Cara Thompson
👩‍💻 Psychology PhD %>%
Analysis of postgraduate medical examinations %>%
Freelance data consultant specialising in dataviz and “enhanced” reproducible outputs
đź’™ Helping others maximise the impact of their expertise
Find out more: cararthompson.com/about
To equip you with some design tips and coding tricks to enhance the story-telling capabilities of your plots.
{ggplot2}
and introducing {ggtext}
{palmerpenguins}
)The penguins had a baking competition to see which species could make the best banana loaf. Each species was given bananas of a different level of ripeness.
The penguins had a baking competition to see which species could make the best banana loaf. Each species was given bananas of a different level of ripeness.
The Adelie penguins decided to experiment with different quantities of banana in their mix. Each island chose a different quantity.
The Adelie penguins decided to experiment with different quantities of banana in their mix. Each island chose a different quantity.
The penguins also baked their cakes for different amounts of time. Here are the mean durations per species. Which species left their cakes in the oven for longest?
The penguins also baked their cakes for different amounts of time. Here are the mean durations per species. Which species left their cakes in the oven for longest?
Make it easy for the readers to remember what is what.
But my research isn’t about bananas!
We first let’s modify the data, so that we have banana quantities to visualise!
library(palmerpenguins)
library(tidyverse)
penguins <- palmerpenguins::penguins %>%
mutate(banana_quantity =
case_when(
species == "Adelie" &
island == "Biscoe" ~ 1,
species == "Adelie" &
island == "Dream" ~ 0.6,
species == "Adelie" &
island == "Torgersen" ~ 0,
TRUE ~ 1))
penguins %>%
select(species, island, banana_quantity) %>%
distinct()
# A tibble: 5 x 3
species island banana_quantity
<fct> <fct> <dbl>
1 Adelie Torgersen 0
2 Adelie Biscoe 1
3 Adelie Dream 0.6
4 Gentoo Biscoe 1
5 Chinstrap Dream 1
Ripeness & quantities, baking duration (bill depth), yumminess (bill length)
Ripeness & quantities, baking duration (bill depth), yumminess (bill length)
Ripeness & quantities, baking duration (bill depth), yumminess (bill length)
Ripeness & quantities, baking duration (bill depth), yumminess (bill length)
Ripeness & quantities, baking duration (bill depth), yumminess (bill length)
basic_plot <- ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
colour = species)) +
geom_point(aes(alpha = banana_quantity)) +
labs(title = "Banana loaf tastes best when baked with ripe or over-ripe bananas",
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness.
The Adelie penguins were given unripe bananas, Gentoos were given over-ripe
bananas and Chinstraps were given yellow bananas.
Each penguin was left to choose their own cooking time.",
x = "Baking time",
y = "Yumminess",
caption = "Data from {palmerpenguins}; misused for illustration purposes.") +
scale_alpha(range = c(0.2, 1)) +
theme_minimal(base_size = 16)
basic_plot
Ripeness & quantities, baking duration (bill depth), yumminess (bill length)
basic_plot <- ggplot(penguins,
aes(x = bill_depth_mm,
y = bill_length_mm,
colour = species)) +
geom_point(aes(alpha = banana_quantity)) +
labs(title = "Banana loaf tastes best when baked with ripe or over-ripe bananas",
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness.
The Adelie penguins were given unripe bananas, Gentoos were given over-ripe
bananas and Chinstraps were given yellow bananas.
Each penguin was left to choose their own cooking time.",
x = "Baking time",
y = "Yumminess",
caption = "Data from {palmerpenguins}; misused for illustration purposes.") +
scale_alpha(range = c(0.2, 1)) +
theme_minimal(base_size = 12)
basic_plot
Adelie = Unripe, Chinstrap = Ripe, Gentoo = Over-ripe
The quick fix…
… might be a dangerous shortcut!
ggplot(penguins %>%
# Oh, that should be a factor,
# let me fix that for you!
mutate(species =
factor(species,
levels = c("Chinstrap",
"Gentoo",
"Adelie"))),
aes(x = bill_depth_mm,
y = bill_length_mm,
colour = species)) +
geom_point() +
theme_minimal() +
scale_colour_manual(values = c("#89973d",
"#e8b92f",
"#a45e41"))
Create a named list!
Create a named list!
banana_colours <- list("Adelie" = "#89973d",
"Chinstrap" = "#e8b92f",
"Gentoo" = "#a45e41")
ggplot(penguins %>%
# Oh, that should be a factor,
# let me fix that for you!
mutate(species =
factor(species,
levels = c("Chinstrap",
"Gentoo",
"Adelie"))),
aes(x = bill_depth_mm,
y = bill_length_mm,
colour = species)) +
geom_point() +
theme_minimal() +
scale_colour_manual(values = banana_colours)
Create a named list!
Choosing colours is tricky!
Find out more: blog.datawrapper.de/colors-for-data-vis-style-guides/
We’ve done this already!
Say hello to 📦 {ggtext}
Say hello to 📦 {ggtext}
[1] "Banana loaf tastes best when baked with <span style=\"color:#e8b92f\">ripe</span> or <span style=\"color:#a45e41\">over-ripe</span> bananas"
Say hello to 📦 {ggtext}
library(ggtext)
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">ripe</span> or <span style=\"color:",
banana_colours$Gentoo, "\">over-ripe</span> bananas")) +
theme(plot.title = element_markdown())
Say hello to 📦 {ggtext}
library(ggtext)
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or <span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(plot.title = element_markdown())
Find out more: https://www.interaction-design.org/
Two more colours for our palette
dark_text <- monochromeR::generate_palette(
banana_colours$Chinstrap, "go_darker",
n_colours = 2)[2]
light_text <- monochromeR::generate_palette(
dark_text, "go_lighter",
n_colours = 3)[2]
banana_colours <- list("Adelie" = "#89973d",
"Chinstrap" = "#e8b92f",
"Gentoo" = "#a45e41",
"dark_text" = dark_text,
"light_text" = light_text)
monochromeR::view_palette(banana_colours)
Where we were…
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or <span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(plot.title = element_markdown())
Where we were…
basic_plot +
scale_colour_manual(values = banana_colours,
limits = force) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or <span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(plot.title = element_markdown())
Add a base colour and font for text
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or <span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(text = element_text(family = "DM Sans",
colour = banana_colours$light_text),
plot.title = element_markdown())
Override it in the title
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or <span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(text = element_text(family = "DM Sans",
colour = banana_colours$light_text),
plot.title = element_markdown(colour = banana_colours$dark_text))
Change the font and size of the title
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or <span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(text = element_text(family = "DM Sans",
colour = banana_colours$light_text),
plot.title = element_markdown(
size = 18,
family = "Poppins",
colour = banana_colours$dark_text,
face = "bold")
)
Add a line<br>
eak
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">**ripe**</span> or<br><span style=\"color:",
banana_colours$Gentoo, "\">**over-ripe**</span> bananas")) +
theme(text = element_text(family = "DM Sans",
colour = banana_colours$light_text),
plot.title = element_markdown(
size = 18,
family = "Poppins",
colour = banana_colours$dark_text,
face = "bold")
)
Apply the same principle to the axes and caption
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0(
"Banana loaf tastes best when baked with ",
"<span style=\"color:", banana_colours$Chinstrap,
"\">ripe</span> or<br><span style=\"color:",
banana_colours$Gentoo, "\">over-ripe</span> bananas")) +
theme(text = element_text(family = "DM Sans",
colour = banana_colours$light_text),
plot.title = element_markdown(
size = 18,
family = "Poppins",
colour = banana_colours$dark_text,
face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6))
Getting custom fonts to work can be frustrating!
Install fonts locally +
{ragg}
+{systemfonts}
+{textshaping}
+ Set graphics device to “AGG” + 🤞
Combine all the above to create text boxes instead of a legend!
# Create a new tibble
penguin_summaries <- palmerpenguins::penguins %>%
group_by(species) %>%
summarise(bill_depth_mm = mean(bill_depth_mm, na.rm = TRUE),
bill_length_mm = mean(bill_length_mm, na.rm = TRUE)) %>%
mutate(commentary = case_when(species == "Adelie" ~
"The Adelie penguins tried varying the amount of banana in the mix.
Turns out, even a hint of green banana is detrimental to yumminess!",
species == "Gentoo" ~
"Over-ripe bananas and typically shorter baking times.",
TRUE ~ "Ripe bananas and slightly longer cooking times."))
Combine all the above to create text boxes instead of a legend!
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas")) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6))
Combine all the above to create text boxes instead of a legend!
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas")) +
geom_textbox(data = penguin_summaries,
aes(label = paste0(
"**Team ", species, "**",
"<br><span style = \"color:",
banana_colours$light_text,
"\">", commentary, "</span>"))) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6))
Combine all the above to create text boxes instead of a legend!
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas")) +
geom_textbox(data = penguin_summaries,
aes(label = paste0(
"**Team ", species, "**",
"<br><span style = \"color:",
banana_colours$light_text,
"\">", commentary, "</span>")),
family = "DM Sans",
size = 3.5,
width = unit(9, "line"),
alpha = 0.9,
box.colour = NA) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6))
Combine all the above to create text boxes instead of a legend!
basic_plot +
scale_colour_manual(values = banana_colours, limits = force) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness.
Each penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0(
"**Team ", species, "**",
"<br><span style = \"color:",
banana_colours$light_text,
"\">", commentary, "</span>")),
family = "DM Sans",
size = 3.5,
width = unit(9, "line"),
alpha = 0.9,
box.colour = NA) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
First, a bit of text manipulation!
First, a bit of text manipulation!
penguin_highlights <- palmerpenguins::penguins_raw %>%
# Housekeeping
janitor::clean_names() %>%
rename(bill_depth_mm = culmen_depth_mm,
bill_length_mm = culmen_length_mm) %>%
# Find star baker, runner up and lowest score
filter(bill_length_mm %in% c(max(bill_length_mm, na.rm = TRUE),
sort(bill_length_mm, decreasing = TRUE)[2],
min(bill_length_mm, na.rm = TRUE)))
First, a bit of text manipulation!
penguin_highlights <- palmerpenguins::penguins_raw %>%
janitor::clean_names() %>%
rename(bill_depth_mm = culmen_depth_mm,
bill_length_mm = culmen_length_mm) %>%
filter(bill_length_mm %in% c(max(bill_length_mm, na.rm = TRUE),
sort(bill_length_mm, decreasing = TRUE)[2],
min(bill_length_mm, na.rm = TRUE))) %>%
# More housekeeping
mutate(species = gsub("(.) (.*)", "\\1", species))
First, a bit of text manipulation!
penguin_highlights <- palmerpenguins::penguins_raw %>%
janitor::clean_names() %>%
rename(bill_depth_mm = culmen_depth_mm,
bill_length_mm = culmen_length_mm) %>%
filter(bill_length_mm %in% c(max(bill_length_mm, na.rm = TRUE),
sort(bill_length_mm, decreasing = TRUE)[2],
min(bill_length_mm, na.rm = TRUE))) %>%
mutate(species = gsub("(.) (.*)", "\\1", species),
# Add commentary!
commentary = case_when(
bill_length_mm == max(bill_length_mm) ~
paste0("Our star baker is **", individual_id,
"**, a ", species, " from ", island,
". Congratulations, ", individual_id, "!"),
bill_length_mm == sort(bill_length_mm, decreasing = TRUE)[2] ~
paste0("Our runner up is a ", species,
" from ", island, ": **", individual_id,
"**, proving that ripe and over-ripe bananas are both good options!"),
TRUE ~ paste0("**", individual_id,
"**, did not have a good baking day. The combination of short cooking time and green bananas probably didn't help!")))
Next, let’s work out where we want our labels…
… and add box coordinates and text alignment to our data
penguin_highlights <- palmerpenguins::penguins_raw %>%
janitor::clean_names() %>%
rename(bill_depth_mm = culmen_depth_mm,
bill_length_mm = culmen_length_mm) %>%
filter(bill_length_mm %in% c(max(bill_length_mm, na.rm = TRUE),
sort(bill_length_mm, decreasing = TRUE)[2],
min(bill_length_mm, na.rm = TRUE))) %>%
# more housekeeping!
arrange(bill_length_mm) %>%
mutate(species = gsub("(.) (.*)", "\\1", species),
commentary = case_when(
bill_length_mm == max(bill_length_mm) ~
paste0("Our star baker is **", individual_id, "**, a ", species, " from ", island, ". Congratulations, ", individual_id, "!"),
bill_length_mm == sort(bill_length_mm, decreasing = TRUE)[2] ~
paste0("Our runner up is a ", species, " from ", island, ": **", individual_id, "**, proving that ripe and over-ripe bananas are both good options!"),
TRUE ~ paste0("**", individual_id, "**, did not have a good baking day. The combination of short cooking time and green bananas probably didn't help!")),
# Add label and arrow coordinates
label_x = c(15, 18.15, 16.45),
label_y = c(34, 57, 59),
left_to_right = case_when(label_x < bill_depth_mm ~ 1,
TRUE ~ 0),
arrow_x_end = case_when(label_x < bill_depth_mm ~ bill_depth_mm - 0.1,
TRUE ~ bill_depth_mm + 0.1),
arrow_y_end = case_when(label_y < bill_length_mm ~ bill_length_mm - 0.1,
TRUE ~ bill_length_mm + 0.1))
Find out more: cararthompson.com/posts/2021-09-02-alignment-cheat-sheet/
Let’s add the annotations…
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
Let’s add the annotations…
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary,
x = label_x,
y = label_y,
hjust = left_to_right),
family = "DM Sans",
size = 3,
fill = NA,
box.colour = NA) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
… using arrows and alignments to emphasise the story
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary, x = label_x, y = label_y, hjust = left_to_right),
family = "DM Sans", size = 3, fill = NA, box.colour = NA) +
geom_curve(data = penguin_highlights,
aes(x = label_x, xend = arrow_x_end,
y = label_y, yend = arrow_y_end,
hjust = left_to_right),
arrow = arrow(length = unit(0.1, "cm")),
curvature = list(0.15),
alpha = 0.5) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
… using arrows and alignments to emphasise the story
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary, x = label_x, y = label_y, hjust = left_to_right,
halign = left_to_right),
family = "DM Sans", size = 3, fill = NA, box.colour = NA) +
geom_curve(data = penguin_highlights,
aes(x = label_x, xend = arrow_x_end,
y = label_y, yend = arrow_y_end),
arrow = arrow(length = unit(0.1, "cm")),
curvature = list(0.15),
alpha = 0.5) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
Increase lineheight, reduce distractions
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary, x = label_x, y = label_y, hjust = left_to_right, halign = left_to_right),
family = "DM Sans", size = 3, fill = NA, box.colour = NA) +
geom_curve(data = penguin_highlights,
aes(x = label_x, xend = arrow_x_end, y = label_y, yend = arrow_y_end),
arrow = arrow(length = unit(0.1, "cm")), curvature = list(0.15), alpha = 0.5) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
Increase lineheight, reduce distractions
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary, x = label_x, y = label_y, hjust = left_to_right, halign = left_to_right),
family = "DM Sans", size = 3, fill = NA, box.colour = NA) +
geom_curve(data = penguin_highlights,
aes(x = label_x, xend = arrow_x_end, y = label_y, yend = arrow_y_end),
arrow = arrow(length = unit(0.1, "cm")), curvature = list(0.15), alpha = 0.5) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text,
lineheight = 1.2),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
legend.position = "none")
Increase lineheight, reduce distractions
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary, x = label_x, y = label_y, hjust = left_to_right, halign = left_to_right),
family = "DM Sans", size = 3, fill = NA, box.colour = NA) +
geom_curve(data = penguin_highlights,
aes(x = label_x, xend = arrow_x_end, y = label_y, yend = arrow_y_end),
arrow = arrow(length = unit(0.1, "cm")), curvature = list(0.15), alpha = 0.5) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text,
lineheight = 1.2),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
panel.grid = element_line(colour = "#F6F6F5"),
legend.position = "none")
Increase lineheight, reduce distractions, check everything fits!
basic_plot +
scale_colour_manual(values = banana_colours) +
labs(title = paste0("Banana loaf tastes best when baked with <span style=\"color:", banana_colours$Chinstrap, "\">ripe</span> or<br><span style=\"color:", banana_colours$Gentoo, "\">over-ripe</span> bananas"),
subtitle = "The Palmer Penguins carried out an experiment using bananas of different ripeness. \nEach penguin was left to choose their own cooking time.") +
geom_textbox(data = penguin_summaries,
aes(label = paste0("**Team ", species, "**", "<br><span style = \"color:", banana_colours$light_text, "\">", commentary, "</span>")),
family = "DM Sans", size = 3.5, width = unit(9, "line"), alpha = 0.9, box.colour = NA) +
geom_textbox(data = penguin_highlights,
aes(label = commentary, x = label_x, y = label_y, hjust = left_to_right, halign = left_to_right),
family = "DM Sans", size = 3, fill = NA, box.colour = NA) +
geom_curve(data = penguin_highlights,
aes(x = label_x, xend = arrow_x_end, y = label_y, yend = arrow_y_end),
arrow = arrow(length = unit(0.1, "cm")), curvature = list(0.15), alpha = 0.5) +
scale_x_continuous(expand = expansion(mult = c(0.2, 0.02))) +
theme(text = element_text(family = "DM Sans", colour = banana_colours$light_text,
lineheight = 1.2),
plot.title = element_markdown(size = 18, family = "Poppins", colour = banana_colours$dark_text, face = "bold"),
axis.text = element_text(size = 6),
plot.caption = element_text(size = 6),
panel.grid = element_line(colour = "#F6F6F5"),
legend.position = "none")
Slides and recording: cararthompson.com/talks/hdsi_rug