xyplot.ts
位於 lattice
包(package)。 說明
此函數處理時間序列繪圖,包括cut-and-stack 繪圖。給出了疊加、並置和設置不同時間序列樣式的示例。
用法
## S3 method for class 'ts'
xyplot(x, data = NULL,
screens = if (superpose) 1 else colnames(x),
...,
superpose = FALSE,
cut = FALSE,
type = "l",
col = NULL,
lty = NULL,
lwd = NULL,
pch = NULL,
cex = NULL,
fill = NULL,
auto.key = superpose,
panel = if (superpose) "panel.superpose"
else "panel.superpose.plain",
par.settings = list(),
layout = NULL, as.table = TRUE,
xlab = "Time", ylab = NULL,
default.scales = list(y = list(relation =
if (missing(cut)) "free" else "same")))
參數
x |
類 |
data |
未使用,必須保留為 |
... |
傳遞給 |
screens |
因子(或強製因子),其級別指定每個係列要在哪個麵板中繪製。 |
superpose |
將所有係列覆蓋在一個麵板中(通過 |
cut |
定義cut-and-stack圖。
|
type , col , lty , lwd , pch , cex , fill |
圖形參數,經過處理並最終傳遞給 |
auto.key |
邏輯或說明如何繪製 key 的列表。請參閱 |
panel |
麵板函數。建議不要管它,但可以傳遞 |
par.settings |
超出標準的樣式設置 |
layout |
長度為 2 的數值向量,指定圖中的列數和行數。默認情況下,列最多填充 6 行。 |
as.table |
從上到下繪製麵板。順序由 |
xlab , ylab |
X軸和Y軸標簽;請參閱 |
default.scales |
|
細節
對於多元序列來說,多個圖形參數的處理更加靈活。這些參數可以是與繪製的係列數量相同長度的向量,或者如果更短則被回收。它們也可以是(部分)命名列表,例如 list(A = c(1,2), c(3,4))
其中 c(3, 4)
是默認值,而 c(1, 2)
僅適用於係列 A
。可以以類似的方式指定screens
參數。
下麵給出一些示例。
值
類 "trellis"
的對象。 update
方法可用於更新對象的組件,print
方法(通常默認調用)會將其繪製在適當的繪圖設備上。
例子
xyplot(ts(c(1:10,10:1)))
### Figure 14.1 from Sarkar (2008)
xyplot(sunspot.year, aspect = "xy",
strip = FALSE, strip.left = TRUE,
cut = list(number = 4, overlap = 0.05))
### A multivariate example; first juxtaposed, then superposed
xyplot(EuStockMarkets, scales = list(y = "same"))
xyplot(EuStockMarkets, superpose = TRUE, aspect = "xy", lwd = 2,
type = c("l","g"), ylim = c(0, max(EuStockMarkets)))
### Examples using screens (these two are identical)
xyplot(EuStockMarkets, screens = c(rep("Continental", 3), "UK"))
xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"))
### Automatic group styles
xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"),
superpose = TRUE)
xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"),
superpose = TRUE, xlim = extendrange(1996:1998),
par.settings = standard.theme(color = FALSE))
### Specifying styles for series by name
xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"),
col = list(DAX = "red", FTSE = "blue", "black"), auto.key = TRUE)
xyplot(EuStockMarkets, screens = list(FTSE = "UK", "Continental"),
col = list(DAX = "red"), lty = list(SMI = 2), lwd = 1:2,
auto.key = TRUE)
### Example with simpler data, few data points
set.seed(1)
z <- ts(cbind(a = 1:5, b = 11:15, c = 21:25) + rnorm(5))
xyplot(z, screens = 1)
xyplot(z, screens = list(a = "primary (a)", "other (b & c)"),
type = list(a = c("p", "h"), b = c("p", "s"), "o"),
pch = list(a = 2, c = 3), auto.key = list(type = "o"))
作者
Gabor Grothendieck, Achim Zeileis, Deepayan Sarkar and Felix Andrews felix@nfrac.org.
The first two authors developed xyplot.ts
in their zoo
package, including the screens
approach. The third author
developed a different xyplot.ts
for cut-and-stack plots in the
latticeExtra
package. The final author fused these together.
參考
Sarkar, Deepayan (2008) Lattice: Multivariate Data Visualization with R, Springer. http://lmdvr.r-forge.r-project.org/ (cut-and-stack plots)
也可以看看
zoo
包中的 xyplot
、 panel.xyplot
、 plot.ts
、 ts
、 xyplot.zoo
。
相關用法
- R xyplot 常見的二變量網格圖
- R panel.xyplot xyplot 的默認麵板函數
- R panel.bwplot bwplot 的默認麵板函數
- R panel.loess 添加黃土平滑的麵板函數
- R lset 修改網格設置的接口 - 已失效
- R panel.axis 繪圖軸刻度和標簽的麵板函數
- R Rows 從列表中提取行
- R panel.number 在繪圖期間訪問輔助信息
- R trellis.par.get 網格顯示的圖形參數
- R update.trellis 檢索和更新網格對象
- R barley 明尼蘇達州大麥試驗的產量數據
- R panel.functions 有用的麵板函數組件
- R prepanel.functions Lattice 有用的 Prepanel 函數
- R simpleTheme 生成簡單主題的函數
- R panel.parallel 並行的默認麵板函數
- R print.trellis 繪製和總結網格對象
- R panel.cloud 雲默認麵板函數
- R packet.panel.default 將數據包與麵板關聯
- R levelplot 水平圖和等高線圖
- R trellis.device 初始化網格顯示
- R cloud 3d 散點圖和線框曲麵圖
- R tmd Tukey 均差圖
- R panel.pairs splom 的默認超級麵板函數
- R draw.colorkey 通常為水平圖生成色鍵
- R prepanel.default 默認預麵板函數
注:本文由純淨天空篩選整理自R-devel大神的英文原創作品 Time series plotting methods。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。