Plot segments using the Trellis framework
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))
x |
Argument on which argument dispatch is carried out. For the
|
data |
An optional data frame, list or environment where
variables in the formula, as well as |
level |
An optional covariate that determines color coding of the segments |
centers |
optional vector of ‘centers’ of the segments.
If specified, points will be plotted at these |
prepanel |
function determining range of the data rectangle from data to be used in a panel. |
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. |
horizontal |
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 |
colorkey |
logical indicating whether a legend showing
association of segment colors to values of |
at, cuts |
|
The 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.
Deepayan Sarkar deepayan.sarkar@r-project.org
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")
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.