LoslegenKostenlos loslegen

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.

Diese Übung ist Teil des Kurses

Communicating with Data in the Tidyverse

Kurs anzeigen

Anleitung zur Übung

  • Fix the label overlap problem by resetting the x-limits of the cartesian coordinate system to 25 and 41. 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.

Interaktive Übung

Versuche dich an dieser Übung, indem du diesen Beispielcode vervollständigst.

# 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
Code bearbeiten und ausführen