panel.xblocks {latticeExtra}R Documentation

Plot contiguous blocks along x axis.

Description

Plot contiguous blocks along x axis.

Usage

panel.xblocks(x, ...)

## Default S3 method:
panel.xblocks(x, y, ..., height = unit(1, "npc"),
              block.y = unit(0, "npc"), vjust = 0,
              col = NULL, border = NA, name = "xblocks",
              last.step = median(diff(tail(x))))

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

Arguments

x, y In the default method, x gives the ordinates along the x axis and must be in increasing order. y gives the colour values to plot as contiguous blocks. These may be character (or factor) values (colour names or hex codes), numbers (indexing palette()), or logicals (where TRUE is palette(1) and FALSE is transparent). Missing values in y are not plotted.
See also col, below, which over-rides values of y.
In the ts method, plot values against their time(), unless y is specified, when it acts just like the default method.
... In the default method, further arguments are graphical parameters passed on to gpar.
height height of blocks, defaulting to the full panel height. Numeric values are interpreted as native units.
block.y y axis position of the blocks. Numeric values are interpreted as native units.
vjust vertical justification of the blocks relative to block.y. See grid.rect.
col if col is specified, then all values of y that are not NA or FALSE are drawn in this colour.
border border colour.
name a name for the grob (grid object).
last.step width (in native units) of the final block. Defaults to the median of the last 5 time steps (assuming steps are regular).

Details

Blocks are drawn forward in "time" from the specified x locations, up until the following value. Contiguous blocks are calculated by rle.

Author(s)

Felix Andrews felix@nfrac.org

See Also

panel.rect, grid.rect

Examples

## Are US presidential approval ratings linked to sunspot activity?

## 'ts' method; set block height, default justification is at bottom.
xyplot(presidents) + layer(panel.xblocks(sunspot.year > 50, height = 3))

## blocks in a light shading colour, full panel height.
xyplot(presidents) +
  layer(panel.xblocks(sunspot.year > 50, col = "#e6e6e6"), under=TRUE)

## multiple colour values given in the 'y' argument.
sscols <- cut(sunspot.year, c(50,150,Inf), labels=c("yellow","orange"))
xyplot(presidents, lwd = 2) +
  layer(panel.xblocks(time(sunspot.year), y = sscols, alpha = 0.5))

[Package latticeExtra version 0.6-4 Index]