如何在ggplot中为不同的时间序列添加标签

时间:2013-06-06 15:19:14

标签: r ggplot2

如何在我的ggplot中添加标签“S& P 500”,“Sotheby”和“Indpro”,以便它们出现在图表和图例中?

g.gspc = ggplot(data = dfm_norm) +
  geom_line(aes(x = Date, y = GSPCM, colour = "blue") +
  geom_line(aes(x = Date, y = BIDM, colour = "red")) +
  geom_line(aes(x = Date, y = INDPROM, colour = "green")) +
  theme_bw()
g.gspc = g.gspc +
  geom_rect(data=recessions.trim, aes(xmin=Peak, xmax=Trough, ymin=-Inf, ymax=+Inf), fill='pink', alpha=0.4) +
  ggtitle("Normalized S&P 500, Sotheby's, and Industrial Production series") +
  xlab("Time") +
  ylab("Normalized Vectors")
plot(g.gspc)

Example graph

我尝试了其他网站和论坛帖子的各种编码示例,没有成功:( 顺便说一句,如果你有任何建议“如何皮条客图”,特别是使用quantmod包,总是赞赏!

0 个答案:

没有答案