Tutorial-10
Creating Infographics
Learning Objectives
Practice iterating and polishing your visualisations
Practice adding additional additive elements to enhance your data narrative
Motivation
Effective communication sometimes requries extending you visualisation by adding narrative elements to guide your audience. This includes elements such as text, highlighting, arrows and labels.
In this tutorial, we’ll practice adding narrative elements to our visualisation, so we can better deliver the key messages to the audience.
Question 1
The following is a basic example from the ggplot2 book from the section on annotations.
That shows how plots can benefit from additional narrative elements.
- Using this code to start. Try adding the text layer to the plot.
presidential <- subset(presidential, start > economics$date[1])
ggplot(economics) +
geom_rect(
data = presidential,
aes(xmin = start, xmax = end, fill = party),
ymin = -Inf, ymax = Inf, alpha = 0.2,
) +
geom_line(aes(date, unemploy)) Fix the colour scale so it appropriately reflects party colours.
Add vertical lines to better distinguish between the different presidencies.
Polish the title, axis labels and legends. Use
?economicsto check what units to use.
Question 2
There are other useful ways to add annotations to your plot such as using the gghighlight package.
if(!require(gghighlight))
install.packages("gghighlight")
library(gghighlight)Take a look at the examples here and examples here
- Use this code to generate a basic plot to start - Warning: It’s not good.
big_tech_data = read_csv("week10/data/big-tech-stock-price.csv")ggplot(big_tech_data) +
geom_line(aes(x= date, y = high, colour = stock_symbol))- Use
gghighlightto show stocks with ahigh > 600. Try looking at?gghighlightto get started.
- Try this slight variation as well using
facet_wrap()
Finishing Up
- Make sure you understand how to position text or a label on your plot by changing the x and y coordinates.
Think how you use colour to highlight your messages.
Lastly, and most importantly, remember don’t always go adding additional elements if they serve your data narrative.