Moving the legend
Let's wrap up this course by making a publication-ready plot communicating a clear message.
To change stylistic elements of a plot, call theme()
and set plot properties to a new value. For example, the following changes the legend position.
p + theme(legend.position = new_value)
Here, the new value can be
"top"
,"bottom"
,"left"
, or"right'"
: place it at that side of the plot."none"
: don't draw it.c(x, y)
:c(0, 0)
means the bottom-left andc(1, 1)
means the top-right.
Let's revisit the recession period line plot (assigned to plt_prop_unemployed_over_time
).
This exercise is part of the course
Introduction to Data Visualization with ggplot2
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# View the default plot
plt_prop_unemployed_over_time
# Remove legend entirely
plt_prop_unemployed_over_time +
___