1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Data Visualization with ggplot2

Exercise

Modifying theme elements

Many plot elements have multiple properties that can be set. For example, line elements in the plot such as axes and gridlines have a color, a thickness (size), and a line type (solid line, dashed, or dotted). To set the style of a line, you use element_line(). For example, to make the axis lines into red, dashed lines, you would use the following.

p + theme(axis.line = element_line(color = "red", linetype = "dashed"))

Similarly, element_rect() changes rectangles and element_text() changes text. You can remove a plot element using element_blank().

plt_prop_unemployed_over_time is available.

Instructions 1/4

undefined XP
    1
    2
    3
    4
  • Give all rectangles in the plot, (the rect element) a fill color of "grey92" (very pale grey).
  • Remove the legend.key's outline by setting its color to be missing.
  • Look at the changes in the plot.