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

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

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

                                         Plot contiguous blocks along x axis.
                                         绘制连续的块沿x轴。

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

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

Plot contiguous blocks along x axis. A typical use would be to highlight events or periods of missing data.
绘制连续的块沿x轴。一个典型的应用是将突出事件或期间丢失的数据。


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


xblocks(x, ...)

## Default S3 method:[默认方法]
xblocks(x, y, ..., col = NULL, border = NA,
        ybottom = par("usr")[3], ytop = ybottom + height,
        height = diff(par("usr")[3:4]),
        last.step = median(diff(tail(x))))

## S3 method for class 'zoo'
xblocks(x, y = x, ...)

## S3 method for class 'ts'
xblocks(x, y = x, ...)



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

参数:x, y
In the default method, x gives the ordinates along the x axis and must be in increasing order. y gives the color values to plot as contiguous blocks. If y is numeric, data coverage is plotted, by converting it into a logical (!is.na(y)). Finally, if y is a function, it is applied to x (time(x) in the time series methods).   If y has character (or factor) values, these are interpreted as colors – and should therefore be color names or hex codes. Missing values in y are not plotted. The default color is taken from palette()[1]. If col is given, this over-rides the block colors given as y.  The ts and zoo methods plot the coredata(y) values against the time index index(x).   
在默认的方法中,x给出了沿x轴的坐标,并且必须以递增顺序。 y给出了绘制连续的块的颜色值。如果y是数字,数据的覆盖面,将其转换成一个逻辑(!is.na(y))绘制。最后,如果y是一个函数,它适用于x(time(x)在时间序列方法)。如果y字符(或因子)值,这些颜色解释为 - ,因此应该是颜色名称或十六进制代码。遗漏值在y不绘制。默认的颜色是从palette()[1]。 col如果,这过乘坐块颜色为y。的ts和zoo方法图coredata(y)值,对时间指数index(x)。


参数:...
In the default method, further arguments are graphical parameters passed on to gpar.  
在默认的方法,进一步的论据是图形化的参数传递给gpar。


参数:col
if col is specified, it determines the colors of the blocks defined by y. If multiple colors are specified they will be repeated to cover the total number of blocks.  
如果col被指定,它决定了颜色的块定义的y。如果指定了多个颜色,它们将被重复覆盖的总块数。


参数:border
border color.  
边框的颜色。


参数:ybottom, ytop, height
y axis position of the blocks. The default it to fill the whole plot region, but by setting these values one can draw blocks along the top of bottom of the plot. Note that height is not used directly, it only sets the default value of ytop.  
Y轴位置的区块。默认情况下,它填补了整个小区区域,但通过设置这些值可以得出一个沿的顶部,底部积块。请注意height不直接使用,它只是设置的默认值ytop。


参数:last.step
width (in native units) of the final block. Defaults to the median of the last 5 time steps (assuming steps are regular).  
最终块的宽度(在本地单位)。默认为最后5步骤(假设步骤是定期)的中位数。


Details

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

Blocks are drawn forward in "time" from the specified x locations, up until the following value. Contiguous blocks are calculated using rle.
块画“时间”,从指定的x位置,直到下面的值。连续的块计算使用rle。


(作者)----------Author(s)----------



Felix Andrews <a href="mailto:felix@nfrac.org">felix@nfrac.org</a>




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

panel.xblocks, rect
panel.xblocks,rect


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


## example time series:[#时间序列的例子:]
set.seed(0)
flow <- ts(filter(rlnorm(200, mean = 1), 0.8, method = "r"))

## highlight values above and below thresholds.[#突出的上面和下面的阈值的值。]
## this draws on top using semi-transparent colors.[由此得出的顶部采用半透明的颜色。]
rgb <- hcl(c(0, 0, 260), c = c(100, 0, 100), l = c(50, 90, 50), alpha = 0.3)
plot(flow)
xblocks(flow &gt; 30, col = rgb[1]) ## high values red[#高值红色]
xblocks(flow &lt; 15, col = rgb[3]) ## low value blue[#低价值的蓝色]
xblocks(flow &gt;= 15 &amp; flow &lt;= 30, col = rgb[2]) ## the rest gray[#截断灰的]

## same thing:[#一样的东西:]
plot(flow)
xblocks(time(flow), cut(flow, c(0,15,30,Inf), labels = rev(rgb)))

## another approach is to plot blocks underneath without transparency.[#另一种方法是绘制块下面没有透明度。]
plot(flow)
## note that 'ifelse' keeps its result as class 'ts'[#注意ifelse保持其结果作为类的TS“]
xblocks(ifelse(flow < mean(flow), hcl(0, 0, 90), hcl(0, 80, 70)))
## need to redraw data series on top:[#需要重绘的数据系列之上:]
lines(flow)
box()

## for single series only: plot.default has a panel.first argument[#单系列:plot.default有一个panel.first的参数]
plot(time(flow), flow, type = "l",
  panel.first = xblocks(flow > 20, col = "lightgray"))
## (see also the 'panel' argument for use with multiple series, below)[#(见“面板”的说法多个系列的使用,下文)]

## insert some missing values[#插入一些失踪的值。]
flow[c(1:10, 50:80, 100)] <- NA

## the default plot shows data coverage[#默认图形显示数据的覆盖面]
## (most useful when displaying multiple series, see below)[#(显示多个系列时最有用的,见下文)]
plot(flow)
xblocks(flow)

## can also show gaps:[#也显示空白:]
plot(flow, type = "s")
xblocks(time(flow), is.na(flow), col = "gray")

## Example of alternating colors, here showing calendar months[#示例交替的颜色,在这里表现出历月]
flowdates <- as.Date("2000-01-01") + as.numeric(time(flow))
flowz <- zoo(coredata(flow), flowdates)
plot(flowz)
xblocks(flowz, months, ## i.e. months(time(flowz)),[#即个月(时间(flowz)个月),]
  col = gray.colors(2, start = 0.7), border = "slategray")
lines(flowz)

## Example of multiple series.[#示例多个系列。]
## set up example data[#设置示例数据]
z <- ts(cbind(A = 0:5, B = c(6:7, NA, NA, 10:11), C = c(NA, 13:17)))

## show data coverage only (highlighting gaps)[#显示数据的覆盖面(突出的差距)]
plot(z, panel = function(x, ...)
  xblocks(x, col = "darkgray"))

## draw gaps in darkgray[#画差距,深灰]
plot(z, type = "s", panel = function(x, ...) {
  xblocks(time(x), is.na(x), col = "darkgray")
  lines(x, ...); points(x)
})

## Example of overlaying blocks from a different series.[#示例覆盖块从不同的系列。]
## Are US presidential approval ratings linked to sunspot activity?[#美国总统的支持率与太阳黑子活动吗?]
## Set block height to plot blocks along the bottom.[#设置块的高度,地积块沿底部。]
plot(presidents)
xblocks(sunspot.year > 50, height = 2)

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


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

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 21:52 , Processed in 0.022477 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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