移动图例
让我们以一个可发表的、信息明确的图表为本课程收尾。
若要更改图表的样式元素,调用 theme() 并将相应的属性设为新值。例如,下面的代码可以更改图例的位置。
p + theme(legend.position = new_value)
其中,new_value 可以是:
"top"、"bottom"、"left"或"right'":将图例放在图的对应边。"none":不绘制图例。c(x, y):c(0, 0)表示左下角,c(1, 1)表示右上角。
让我们回到经济衰退时期的折线图(已保存为 plt_prop_unemployed_over_time)。
本练习是课程的一部分
使用 ggplot2 进行数据可视化入门
交互式实操练习
通过完成这段示例代码来试试这个练习。
# View the default plot
plt_prop_unemployed_over_time
# Remove legend entirely
plt_prop_unemployed_over_time +
___