【发布时间】:2022-01-09 23:14:27
【问题描述】:
我在 R 中使用 ggplot() 生成了一个图,我想生成一个图例来解释我覆盖在数据上的垂直虚线,而不是数据本身。是否可以创建自定义图例,仅对 geom_vline 组件进行说明?
我的代码是这样的:
ggplot(weektotals, aes(x=week, y=total)) + geom_line(color="red") + geom_point() + geom_vline(xintercept=as.Date("27/03/20", format = "%d/%m/%y"), linetype="dotted", color="darkred", size=1)
提前致谢!
【问题讨论】:
-
尝试:
geom_vline(aes(xintercept=as.Date("27/03/20", format = "%d/%m/%y"), color="darkred"), linetype="dotted", size=1)使用颜色作为图例的起点
标签: r ggplot2 customization legend