Working with Text
11:00-12:30
View slides in full screen | Run the code yourself
Outline
- Labels +
theme()
- Labels +
scale_*()
- Styling Labels with
{ggtext}
- Facet Labellers
- Handling Long Labels
- Annotations
- Exercises
Recap
- style labels such as title, axis and legend texts with
theme()
- format data-related labels with the
labels
argument ofscale_*()
- adjust strip text with the
facet_*(labeller)
functionality - add data-related annotations with
geom_text|label()
- … and data-unrelated annotations with
annotate()
{ggtext}
allows to render labels with markdown and basic html{ggtext}
also allows to add dynamic linebreaks and images{ggrepel}
ensures clever placement of annotationsggforce::geom_mark_*()
provide a set of advanced annotations
Exercises
Exercise 1
- Take a look at the following visualization.
- For each group of text labels, note how one would add and modify them.
- Discuss how to automate the placement of the labels in- and outside of the bars.
Exercise 2
- Create a function that plots the famous Gapminder chart, highlighting one of the continents.
- Extend the code in
02-text-exercises.qmd
to annotate a continent your choice of with {ggforce}. - Turn the code into a function with the utility to annotate any continent.
- Optional: Create a second function to highlight a country.
- Extend the code in