This function can be used to systematically draw segments using a formula interface to produce Trellis displays using the lattice package. Segments can be drawn either as lines or bars, and can be color coded by the value of a covariate, with a suitable legend.
segplot(x, data, ...) ## S3 method for class 'formula': segplot((x, data, level = NULL, centers = NULL, prepanel = prepanel.segplot, panel = panel.segplot, xlab = NULL, ylab = NULL, horizontal = TRUE, ..., at, cuts = 30, colorkey = !is.null(level)))
- Argument on which argument dispatch is carried out. For the
"formula"method, a formula of the form
y ~ x1 + x2(with further conditioning variables appended if necessary). The terms in the formula must all be vectors of the same length. Each element causes a line segment or rectangle to be drawn, with the vertical location determined by
yand horizontal endpoints determined by
- An optional data frame, list or environment where variables in the formula, as well as
level, will be evaluated.
- An optional covariate that determines color coding of the segments
- optional vector of ‘centers’ of the segments. If specified, points will be plotted at these
- function determining range of the data rectangle from data to be used in a panel.
- function to render the graphic given the data. This is the function that actually implements the display.
- xlab, ylab
- Labels for the axes. By default both are missing.
- logical, whether the segments are to be drawn horizontally (the default) or vertically. This essentially swaps the role of the x- and y-axes in each panel.
- further arguments. Arguments to
levelplotas well as to the default panel function
panel.segplotcan be supplied directly to
- logical indicating whether a legend showing association of segment colors to values of
levelshould be shown, or a list to control details of such a color key. See details below.
- at, cuts
atspecifies the values of
levelwhere the color code changes. If
atis missing, it defaults to
cutsequispaced locations spanning the range of
levelplot function from the lattice package is used to internally to implement this function. In particular, the colorkey mechanism is used as it is, and documentation for
levelplot should be consulted to learn how to fine tune it.
Currently only horizontal segments are supported. Vertical segments can be obtained by modifying the prepanel and panel functions suitably.
segplot(factor(1:10) ~ rnorm(10) + rnorm(10), level = runif(10)) data(USCancerRates) segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington")) segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"), draw.bands = FALSE, centers = rate.male) segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"), level = rate.female, col.regions = terrain.colors) segplot(reorder(factor(county), rate.male) ~ LCL95.male + UCL95.male, data = subset(USCancerRates, state == "Washington"), draw.bands = FALSE, centers = rate.male, segments.fun = panel.arrows, ends = "both", angle = 90, length = 1, unit = "mm")
Documentation reproduced from package latticeExtra, version 0.6-28. License: GPL (>= 2)