Add labels to the plot
As mentioned in the video, you're going to enhance the plot from the previous exercise by adding a title, a subtitle, and a caption to the plot as well as giving the axes meaningful names. You're going to use the labs() function to do this – try using ?labs in the console to see the available options.
Deze oefening maakt deel uit van de cursus
Communicating with Data in the Tidyverse
Oefeninstructies
- Use the
labs()function to annotate your plot. - Specify the correct arguments in the
labsfunction call.- Use
?labsto fire up the help function and see what arguments thelabs()call takes. - While it should be clear to what arguments most of the annotations should go,
"The more people work, the less compensation they seem to receive"should be the title of the plot.
- Use
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
# Create the plot
ggplot(plot_data) +
geom_point(aes(x = working_hours, y = hourly_compensation)) +
# Add labels
___(
___ = "Working hours per week",
___ = "Hourly compensation",
___ = "The more people work, the less compensation they seem to receive",
___ = "Working hours and hourly compensation in European countries, 2006",
___ = "Data source: ILO, 2017"
)