Change the viewport so labels don't overlap with plot border
Use a function introduced in the previous video to change the viewport of the plotting area. Also apply your custom theme.
This exercise is part of the course
Communicating with Data in the Tidyverse
Exercise instructions
- Fix the label overlap problem by resetting the x-limits of the cartesian coordinate system to
25
and41
. Make sure to use a function that doesn't clip the geometries in your plot. - Remember your custom
theme_ilo()
function? Apply it to the plot.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Reuse ilo_dot_plot
ilo_dot_plot <- ilo_dot_plot +
# Add labels to the plot
labs(
x = "Working hours per week",
y = "Country",
title = "People work less in 2006 compared to 1996",
subtitle = "Working hours in European countries, development since 1996",
caption = "Data source: ILO, 2017"
) +
# Apply your theme
___ +
# Change the viewport
___(___ = c(___, ___))
# View the plot
ilo_dot_plot