将图保存为变量
可以将图形保存为变量,之后再用 + 运算符继续添加图层。若要基于同一个基础图生成多个相关图,这会非常有用。
本练习是课程的一部分
使用 ggplot2 进行数据可视化入门
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Draw a ggplot
plt_price_vs_carat <- ___(
# Use the diamonds dataset
___,
# For the aesthetics, map x to carat and y to price
___(___, ___)
)
# Add a point layer to plt_price_vs_carat
___ + ___