将图例添加到R中的绘图

时间:2017-04-03 09:46:24

标签: r time-series

您好我希望为以下几行创建一个图例,但我不确定如何。

lines1<- lines(salesARIMAPredict$pred, lty = 5, col = "Blue")
lines(salesARIMAPredict$pred+2*salesARIMAPredict$se, col = "Red") #Confidence Interval of 95%
lines(salesARIMAPredict$pred-2*salesARIMAPredict$se, col = "Red")

See Attached

非常感谢赛义夫

1 个答案:

答案 0 :(得分:-1)

在提问之前,您应该做一些基础研究:https://stat.ethz.ch/R-manual/R-devel/library/graphics/html/legend.html

编辑:

为此我创建了这个简单的例子:

ts.plot(ldeaths)
lines(ldeaths+100, col ="red")
legend("top", c("ldeaths", "+100"), col = c("black", "red"), lty = 1)