修改主题元素
许多图形元素都可以设置多个属性。例如,图中的线条元素(如坐标轴和网格线)具有颜色、粗细(size)和线型(实线、虚线或点线)。要设置线条样式,请使用 element_line()。例如,将坐标轴线设置为红色虚线,可使用:
p + theme(axis.line = element_line(color = "red", linetype = "dashed"))
类似地,element_rect() 用于修改矩形,element_text() 用于修改文本。您可以使用 element_blank() 移除某个图形元素。
已提供 plt_prop_unemployed_over_time。
本练习是课程的一部分
使用 ggplot2 进行数据可视化入门
交互式实操练习
通过完成这段示例代码来试试这个练习。
plt_prop_unemployed_over_time +
theme(
# For all rectangles, set the fill color to grey92
___ = ___(___ = ___),
# For the legend key, turn off the outline
___
)