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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。