我在网上找到了一些答案,但由于我解释错误,所以无法使其正常工作。我的目标是简单地使用
xts
绘图功能(包括它创建轴、网格线等的方式)绘制多个图表:x <- xts(data.frame(a=1:100, b=100:1),seq(from=as.Date("2010-01-01"), by="days", len=100))
> plot(x, screens=1)
Warning messages:
1: In plot.xts(x, screens = 1) :
only the univariate series will be plotted
2: In plot.window(...) : "screens" is not a graphical parameter
3: In plot.xy(xy, type, ...) : "screens" is not a graphical parameter
4: In axis(1, at = xycoords$x, labels = FALSE, col = "#BBBBBB", ...) :
"screens" is not a graphical parameter
5: In axis(1, at = xycoords$x[ep], labels = names(ep), las = 1, lwd = 1, :
"screens" is not a graphical parameter
6: In axis(2, ...) : "screens" is not a graphical parameter
7: In title(screens = 1) : "screens" is not a graphical parameter
再试一次:
> plot(x, plot.type="single")
Warning messages:
1: In plot.xts(x, plot.type = "single") :
only the univariate series will be plotted
2: In plot.window(...) : "plot.type" is not a graphical parameter
3: In plot.xy(xy, type, ...) : "plot.type" is not a graphical parameter
4: In axis(1, at = xycoords$x, labels = FALSE, col = "#BBBBBB", ...) :
"plot.type" is not a graphical parameter
5: In axis(1, at = xycoords$x[ep], labels = names(ep), las = 1, lwd = 1, :
"plot.type" is not a graphical parameter
6: In axis(2, ...) : "plot.type" is not a graphical parameter
7: In title(plot.type = "single") :
"plot.type" is not a graphical parameter
需要明确的是:使用lines
可以实现这一点,但我想知道是否有一种一次性完成所有操作的方法。
xtsExtra
中,它警告说xtsExtra::plot.xts
已被弃用,应该使用xts::plot.xts
,但是xts::plot.xts
仍然无法处理多个时间序列,而xtsExtra::plot.xts
实际上不会生成绘图。 - tchakravarty