IniziaInizia gratis

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.

Questo esercizio fa parte del corso

Introduction to Data Visualization with ggplot2

Visualizza il corso

Esercizio pratico interattivo

Prova a risolvere questo esercizio completando il codice di esempio.

plt_prop_unemployed_over_time +
  theme(
    # For all rectangles, set the fill color to grey92
    ___ = ___(___ = ___),
    # For the legend key, turn off the outline
    ___
  )
Modifica ed esegui il codice