Apply the new theme function to the plot
Once you have created your own theme_ilo() function, it is time to apply it to a plot object. In the video you saw that theme() calls can be chained. You're going to make use of this and add another theme() call to adjust some peculiarities of the faceted plot.
Diese Übung ist Teil des Kurses
Communicating with Data in the Tidyverse
Anleitung zur Übung
- From now on, you can just add
theme_ilo()to any plot object you wish. Try it out! Overwrite theilo_plotvariable sotheme_ilo()is applied permanently. - Combine your custom theme function with even further
theme()calls to flexibly adjust settings for advanced plots.- In order to do that, add another
theme()call after thetheme_ilo()call. - Change the background
fillof the facet labels to"gray60"and theircolorto"gray95", using thestrip.backgroundargument. - Change the
colorof the facet labels to"white".
- In order to do that, add another
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# Apply your theme function (dont't forget to call it with parentheses!)
ilo_plot <- ilo_plot +
___
# Examine ilo_plot
ilo_plot
ilo_plot +
# Add another theme call
___(
# Change the background fill and color
strip.background = element_rect(___, ___),
# Change the color of the text
strip.text = element_text(___)
)