绘制具有3条曲线的时间序列数据的图形



我有一个很基本的问题,但是我没能找到答案。我想创建一个有三条曲线的图表(时间序列数据),而不使用ts.plot。以下是三个数据集:

a1 <- seq(as.Date("2001-01-01"),as.Date("2021-01-01"),"years")
a2 <- rnorm(21,10,1)
Dollar <- data.frame(a1,a2)
dates <- as.Date(Dollar[,1], "%d.%m.%Y",tz="GMT") 
xtsplot1 <- as.xts(Dollar[,2], dates)

b1 <- seq(as.Date("2001-01-01"),as.Date("2021-01-01"),"years")
b2 <- rnorm(21,10,1)
EURO <- data.frame(b1,b2)
xtsplot2 <- as.xts(EURO[,2], dates)
c1 <- seq(as.Date("2001-01-01"),as.Date("2021-01-01"),"years")
c2 <- rnorm(21,10,1)
YEN <- data.frame(c1,c2)
xtsplot3 <- as.xts(Dollar[,2], dates)

我现在要绘制这三条曲线。我写了下面的代码:

plot(xtsplot1, xtsplot2, xtsplot3, xaxt = "n", xlab = "Time", ylab = "Value", col = 1:3, ann = FALSE)

但是行不通。

有什么建议吗?:)

可以这样使用matplot:

matplot(cbind(xtsplot1, xtsplot2, xtsplot3), xaxt = "n", xlab = "Time", ylab = "Value", col = 1:3, ann = FALSE, type = 'l')

最新更新