【发布时间】:2020-04-20 16:33:21
【问题描述】:
我对 R 很陌生,我正在尝试使用 ggplot2 在一个图表中同时绘制三个时间序列线(使用不同的颜色)。我想为三行添加图例,但无法生成图表的图例。非常感谢您的建议。
代码ggplot ggplot(vn, aes(x=date)) + `ggplot enter code here`
geom_line(aes(y = newcase),size=1, color="red") +
geom_line(aes(y = recovered),color="blue", size=1)+
geom_line(aes(y = confirmed), color="green", linetype="solid", size=1)+
xlab("Date")+
ylab("People")+
scale_x_date(date_breaks = "1 week", date_labels = "%d/%m")
数据
Date confirmed recovered newcase
2020-03-15 56 16 0
2020-03-16 61 16 4
2020-03-17 66 16 3
2020-03-18 75 16 7
【问题讨论】:
-
你的建议真的很有帮助,所以我的问题解决了。非常感谢
标签: r ggplot2 legend linegraph