2012-10-20 53 views
5

Tôi đã tìm thấy một số câu trả lời cho trực tuyến này nhưng vì một số lý do giải thích không chính xác vì tôi không thể làm cho nó hoạt động. Mục tiêu của tôi là chỉ cần sử dụng tính năng xts âm mưu (với cách thức mà nó tạo ra trục, gridlines, vv.) để vẽ nhiều lô:vẽ nhiều đối tượng xts trong một cửa sổ

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 

Một thử:

> 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 

Để được rõ ràng : Tôi có thể làm điều này bằng cách sử dụng lines nhưng tôi tự hỏi nếu có một cách để làm điều này tất cả cùng một lúc.

Trả lời

9

Bạn có thể ép buộc để zoo sử dụng plot.zoo:

plot(as.zoo(x), screens=1) 
plot(as.zoo(x), plot.type='single') 

Hoặc, bạn có thể cài đặt xtsExtra trong đó có một phương pháp mới hơn plot.xts

#install.packages("xtsExtra", repos='http://r-forge.r-project.org') 
library(xtsExtra) 
plot(x, screens=1) 
+6

Trên phiên bản mới nhất của 'xtsExtra' nó cảnh báo rằng' xtsExtra :: plot.xts' không được dùng nữa và sử dụng 'xts :: plot .xts', nhưng 'xts :: plot.xts' vẫn không thể xử lý nhiều chuỗi thời gian, và' xtsExtra :: plot.xts' không thực sự tạo ra một cốt truyện. – tchakravarty

1

Tôi có thể sai nhưng tôi nghĩ plot.xts là không còn là một phần của xtsExtra và đã chuyển sang các xts chính. Source. Có lẽ ghi chú này sẽ giúp mọi người trong tương lai cố gắng tìm ra âm mưu trong xts ..

Các vấn đề liên quan