r - plotting a graph with 3 curves time series data -
i have pretty basic questions, wasn't able find answer. create graph 3 curves (time series data) without using ts.plot. here 3 data sets:
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) i want plot 3 curves. wrote code:
plot(xtsplot1, xtsplot2, xtsplot3, xaxt = "n", xlab = "time", ylab = "value", col = 1:3, ann = false) but doesn't work.
any suggestions? :)
you use matplot follows:
matplot(cbind(xtsplot1, xtsplot2, xtsplot3), xaxt = "n", xlab = "time", ylab = "value", col = 1:3, ann = false, type = 'l')
Comments
Post a Comment