找回密码
 注册
查看: 2172|回复: 0

R语言 zoo包 xyplot.zoo()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-10-2 07:54:16 | 显示全部楼层 |阅读模式
xyplot.zoo(zoo)
xyplot.zoo()所属R语言包:zoo

                                        Plot zoo Series with Lattice
                                         与莱迪思的图动物园系列

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

xyplot methods for time series objects (of class "zoo", "its", or "tis").
xyplot方法对时间序列对象(类"zoo","its"或"tis")。


用法----------Usage----------


## S3 method for class 'zoo'
xyplot(x, data, ...)

## S3 method for class 'zoo'
llines(x, y = NULL, ...)
## S3 method for class 'zoo'
lpoints(x, y = NULL, ...)
## S3 method for class 'zoo'
ltext(x, y = NULL, ...)

panel.segments.zoo(x0, x1, ...)
panel.rect.zoo(x0, x1, ...)
panel.polygon.zoo(x, ...)



参数----------Arguments----------

参数:x, x0, x1
time series object of class "zoo", "its" or  "tis".  For panel.plot.default it should be a numeric vector.
时间序列对象类"zoo","its"或"tis"。对于panel.plot.default它应该是一个数值向量。


参数:y
numeric vector or matrix.
数值向量或矩阵。


参数:data
not used.
不被使用。


参数:...
arguments are passed to xyplot.ts, and may be passed through to xyplot and panel.xyplot.  Some of the commonly used arguments are:     
参数被传递给xyplot.ts,并且可以通过xyplot和panel.xyplot。一些常用的参数有:

screensfactor (or coerced to factor) whose levels specify which graph each series is to be plotted in.  screens = c(1, 2, 1) would plot series 1, 2 and 3 in graphs 1, 2 and 1. This also defines the strip text in multi-panel plots.  
screens因子(或胁迫因子)的水平图要绘制的每个系列都英寸screens = c(1, 2, 1)将绘制图表1,2和1系列1,2和3。这还定义了条文字在多屏显示图。

scales the default is set so that all series have the "same" X axis but "free" Y axis.  See xyplot in the lattice package for more information on scales.   
scales默认的设置,使所有系列"same"X轴,但"free"Y轴。见xyplotlattice更多信息scales包。

layoutnumeric vector of length 2 specifying number of columns and rows in the plot, see xyplot for more details. The default is to fill columns with up to 6 rows.  
layout数字矢量长度为2的指定数目的列和行中的图,请参阅xyplot更多的细节。默认值是填充列6行。

xlabcharacter string used as the X axis label.  
xlab字符串作为X轴标签。

ylabcharacter string used as the Y axis label. If there are multiple panels it may be a character vector the same length as the number of panels, but NOTE in this case the vector should be reversed OR the argument as.table set to FALSE.  
ylab字符串作为Y轴的标签。如果有多个面板,它可能是一个字符向量的长度相同的面板数,但应注意在这种情况下,向量逆转或参数as.table设置为FALSE。

lty, lwd, pch, type, col graphical arguments passed to panel.xyplot. These arguments can also be vectors or (named) lists, see details for more information.     
lty, lwd, pch, type, col图形参数传递给panel.xyplot。这些参数可以是向量或(命名)的列表,请参阅更多信息。


Details

详细信息----------Details----------

xyplot.zoo plots a "zoo", "its" or "tis" object using xyplot.ts from lattice. Series of other classes are coerced to "zoo" first.
xyplot.zoo图"zoo","its"或"tis"反对使用xyplot.tslattice。其他类系列被强制为"zoo"第一。

The handling of several graphical parameters is more flexible for multivariate series. These parameters can be vectors of the same length as the number of series plotted or are recycled if shorter. They can also be (partially) named list, e.g., list(A = c(1,2), c(3,4)) in which c(3, 4) is the default value and c(1, 2) the value only  for series A. The screens argument can be specified in a similar way.
几个图形参数的处理更灵活的多元系列。这些参数可以是相同的长度的向量作为绘制的系列数或再循环倘较短。它们也可以是命名列表(部分),例如,list(A = c(1,2), c(3,4))c(3, 4)是默认值和c(1, 2)系列A值。 screens参数可以指定以类似的方式。

Note that since zoo 1.6-3 plot.panel.default and plot.panel.custom are no longer necessary, as normal panel functions (panel.xyplot by default) will work.
请注意,由于zoo1.6-3plot.panel.default和plot.panel.custom不再是必要的,因为正常的面板功能(panel.xyplot默认情况下)将工作。

Similarly, there are now methods for the generic lattice drawing functions llines, lpoints, and ltext. These can also be called as  panel.lines, panel.points, and panel.text, respectively. The old interfaces (panel.lines.zoo, panel.points.zoo, and panel.text.zoo), will be removed in future versions. panel.polygon.zoo may also be removed.
同样,现在有方法的通用lattice绘图功能llines,lpoints和ltext。这些也被称为panel.lines,panel.points和panel.text,分别。旧的接口(panel.lines.zoo,panel.points.zoo和panel.text.zoo),将在未来的版本中删除。 panel.polygon.zoo也可能被删除。


值----------Value----------

Invisibly returns a "trellis" class object. Printing this object using print will display it.
无形返回一个"trellis"类对象。打印此对象使用print将显示。


参见----------See Also----------

xyplot.ts, zoo,
xyplot.ts,zoo,


实例----------Examples----------


if(require("lattice") & require("grid")) {

set.seed(1)
z <- zoo(cbind(a = 1:5, b = 11:15, c = 21:25) + rnorm(5))

# plot z using same Y axis on all plots[图z使用相同的Y轴的所有图]
xyplot(z, scales = list(y = list(relation = "same", alternating = FALSE)))

# plot a double-line-width running mean on the panel of b.[图双线宽度是指在面板上的b。]
# Also add a grid.[同时也增加了一个网格。]
# We show two ways to do it. [我们表明两种方法可以做到这一点。]

# change strip background to levels of grey[条背景灰度级]
# If you like the defaults, this can be omitted.[如果你喜欢的默认值,可以省略。]
strip.background <- trellis.par.get("strip.background")
trellis.par.set(strip.background = list(col = grey(7:1/8)))


# Number 1.  Using trellis.focus.[号码1。使用trellis.focus。]
print( xyplot(z) )
trellis.focus("panel", 1, 2, highlight = FALSE)
# (or just trellis.focus() for interactive use)[(或trellis.focus()交互使用)]
z.mean <- rollmean(z, 3)
panel.lines(z.mean[,2], lwd = 2)
panel.grid(h = 10, v = 10, col = "grey", lty = 3)
trellis.unfocus()

# Number 2. Using a custom panel routine.[编号2。使用自定义面板程序。]
xyplot(z, panel = function(x, y, ...) {
    if (packet.number() == 2) {
        panel.grid(h = 10, v = 10, col = "grey", lty = 3)
        panel.lines(rollmean(zoo(y, x), 3), lwd = 2)
    }
    panel.xyplot(x, y, ...)
})

# plot a light grey rectangle "behind" panel b[绘制浅灰色的矩形面板b“幕后黑手”]
trellis.focus("panel", 1, 2)
grid.rect(x = 2, w = 1, default.units = "native",
  gp = gpar(fill = "light grey"))
# do.call("panel.xyplot", trellis.panelArgs())[do.call(的“panel.xyplot”,trellis.panelArgs())]
do.call("panel.lines", trellis.panelArgs()[1:2])
trellis.unfocus()
# a better method is to use a custom panel function.[一个更好的方法是使用自定义面板功能。]
# see also panel.xblocks() and layer() in the latticeExtra package.[看到也panel.xblocks()和层()在latticeExtra包。]

# same but make first panel twice as large as others[相同的,但第一个面板的两倍大,因为他们]
lopt <- list(layout.heights = list(panel = list(x = c(2,1,1))))
xyplot(z, lattice.options = lopt)
# add a grid[添加网格]
update(trellis.last.object(), type = c("l", "g"))

# Plot all in one panel.[绘制在一个小组。]
xyplot(z, screens = 1)
# Same with default styles and auto.key:[相同与默认样式和auto.key的:]
xyplot(z, superpose = TRUE)

# Plot first two columns in first panel and third column in second panel.[绘制前两列在第一盘和第三列在第二个面板。]
# Plot first series using points, second series using lines and third[图点,第二个系列的第一个系列用线条和第三]
#  series via overprinting both lines and points[系列,通过加印线和点]
# Use colors 1, 2 and 3 for the three series (1=black, 2=red, 3=green)[使用三个系列的颜色1,2和3(1 =黑,2 =红色,3 =绿色)]
# Make 2nd (lower) panel 3x the height of the 1st (upper) panel[第二面板(低级)3倍的高度的第一(上部)面板]
# Also make the strip background orange.[另外,还要带底色,橙色。]
p <- xyplot(z, screens = c(1,1,2), type = c("p", "l", "o"), col = 1:3,
  par.settings = list(strip.background = list(col = "orange")))
print(p, panel.height = list(y = c(1, 3), units = "null"))

# Example of using a custom axis[例如,使用一个自定义的轴]
# Months are labelled with smaller ticks for weeks and even smaller[个月都标有较小的刻度线数周甚至更小]
# ticks for days.[刻度线天。]
Days <- seq(from = as.Date("2006-1-1"), to = as.Date("2006-8-8"), by = "day")
z1 <- zoo(seq(length(Days))^2, Days)
Months <- Days[format(Days, "%d") == "01"]
Weeks <- Days[format(Days, "%w") == "0"]
print( xyplot(z1, scales = list(x = list(at = Months))) )
trellis.focus("panel", 1, 1, clip.off = TRUE)
panel.axis("bottom", check.overlap = TRUE, outside = TRUE, labels = FALSE,
  tck = .7, at = as.numeric(Weeks))
panel.axis("bottom", check.overlap = TRUE, outside = TRUE, labels = FALSE,
  tck = .4, at = as.numeric(Days))
trellis.unfocus()

trellis.par.set(strip.background = strip.background)

# separate the panels and suppress the ticks on very top[分离板和抑制的刻度上最顶尖的]
xyplot(z, between = list(y = 1), scales = list(tck = c(1,0)))

# left strips but no top strips[左带,但没有顶带]
xyplot(z, screens = colnames(z), strip = FALSE, strip.left = TRUE)

# plot list of zoo objects using different x scales[动物园的对象使用不同的X尺度的图名单]
z.l <- list(
        zoo(cbind(a = rnorm(10), b = rnorm(10)), as.Date("2006-01-01") + 0:9),
        zoo(cbind(c = rnorm(10), d = rnorm(10)), as.Date("2006-12-01") + 0:9)
)
zm <- do.call(merge, z.l)
xlim <- lapply(zm, function(x) range(time(na.omit(x))))
xyplot(zm, xlim = xlim, scale = list(relation = "free"))
# to avoid merging see xyplot.list() in the latticeExtra package.[以避免合并xyplot.list()在latticeExtra包。]

}

## Not run: [#不运行:]
## playwith (&gt;= 0.9)[#playwith(> = 0.9)]
library("playwith")

z3 <- zoo(cbind(a = rnorm(100), b = rnorm(100) + 1), as.Date(1:100))
playwith(xyplot(z3), time.mode = TRUE)
# hold down Shift key and drag to zoom in to a time period.[按住Shift键并拖动放大到一个时间段。]
# then use the horizontal scroll bar.[然后使用水平滚动条。]

# set custom labels; right click on points to view or add labels[设置自定义标签上点右键点击要查看或添加标签]
labs <- paste(round(z3,1), index(z3), sep = "@")
trellis.par.set(user.text = list(cex = 0.7))
playwith(xyplot(z3, type = "o"), labels = labs)

# this returns indexes into times of clicked points [返回索引次点击点]
ids <- playGetIDs()
z3[ids,]

## another example of using playwith with zoo[#另一个例子使用playwith动物园]
# set up data[设置数据]
dat <- zoo(matrix(rnorm(100*100),ncol=100), Sys.Date()+1:100)
colnames(dat) <- paste("Series", 1:100)

# This will give you a spin button to choose the column to plot,[这会给你一个旋转按钮来选择列图,]
# and a button to print out the current series number.[和一个按钮,打印出当前的序列号。]
playwith(xyplot(dat[,c(1,i)]),  parameters = list(i = 1:100,
   do_something = function(playState) print(playState$env$i))


## End(Not run)[#(不执行)]


转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2024-11-23 21:53 , Processed in 0.022405 second(s), 15 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表