View source: R/panel_dumbbell.R
| panel.dumbbell | R Documentation | 
This panel function creates dumbbell charts. Similar to a lollipop chart that shows a single point supported by a horizontal or vertical line, the dumbbell chart shows the minimum and maximum of a distribution connected by a line. The direction of the dumbbell (i.e. vertical or horizontal) can be specified manually, or it is determined from the data automatically (the default).
panel.dumbbell(
  x,
  y,
  groups = NULL,
  subscripts,
  group.number = NULL,
  col_handle = NULL,
  alpha = 1,
  lty = 1,
  lwd = 1,
  direction = NULL,
  ...
)
x, y | 
 (numeric) variables to be plotted  | 
groups | 
 grouping variable passed down from xyplot (does not need to be specified)  | 
subscripts | 
 subscripts passed down from xyplot (does not need to be specified)  | 
group.number | 
 (numeric) internal variable for grouping, does not need to be specified  | 
col_handle | 
 (character, numeric) color of the lollipop handle (defaults to superpose.symbol$col)  | 
alpha, lty, lwd | 
 (numeric) graphical parameters  | 
direction | 
 (character) axis along which the dumbbell is drawn. Possible values that enforce a direction are "vertical" and "horizontal". Default (NULL) is to guess the direction from the input variables  | 
... | 
 other arguments passed to the function  | 
library(lattice)
data(mtcars)
# vertical dumbbells
xyplot(mpg ~ factor(gear), mtcars,
  groups = gear,
  pch = 19, lwd = 2,
  panel = function(x, y, ...) {
    panel.dumbbell(x, y, ...)
  }
)
# horizontal dumbbells
xyplot(factor(gear) ~ mpg, mtcars,
  groups = gear,
  pch = 19, lwd = 2,
  panel = function(x, y, ...) {
    panel.dumbbell(x, y, ...)
  }
)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.