View(PV)
library(ggplot2)
ssplot <- ggplot(PV, aes(x=year)) + geom_line(aes(y = infinite_horizon), color = "darkred", size = 1) + geom_line(aes(y = through_year_75), color="steelblue", size = 1)
print(ssplot + labs(y="Present Value ($, trillions)", x = "Year") + ggtitle("Measures of Unfunded Social Security Obligations, 2003-2020"))
[不幸的是,我还不能发布图像,但是我得到的是一个有两行且没有图例的图形。为什么会这样呢?任何帮助,将不胜感激。谢谢。
很难看到您的数据示例,但是像下面那样重组代码将有助于解决问题:
library(ggplot2)
ssplot <- ggplot(PV, aes(x=year)) +
geom_line(aes(y = infinite_horizon), color = "darkred", size = 1) +
geom_line(aes(y = through_year_75), color="steelblue", size = 1) +
labs(y="Present Value ($, trillions)", x = "Year") +
ggtitle("Measures of Unfunded Social Security Obligations, 2003-2020")
ssplot