Get startedGet started for free

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.

This exercise is part of the course

Communicating with Data in the Tidyverse

View Course

Exercise instructions

  • Use the labs() function to annotate your plot.
  • Specify the correct arguments in the labs function call.
    • Use ?labs to fire up the help function and see what arguments the labs() 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.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# 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"
  )
Edit and Run Code