panel.lollipop: Make a lollipop chart

View source: R/panel_lollipop.R

panel.lollipopR Documentation

Make a lollipop chart

Description

This panel function creates lollipop charts. A lollipo chart is simply an XY-plot where the single points are supported by a horizontal or vertical line originating from one of the axes, or a specified threshold.

Usage

panel.lollipop(
  x,
  y,
  groups = NULL,
  subscripts,
  group.number = NULL,
  col_handle = NULL,
  alpha = 1,
  lty = 1,
  lwd = 1,
  origin = "bottom",
  custom_threshold = NULL,
  ...
)

Arguments

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

origin

(character) axis that serves as starting point for the lollipop handle. One of "top", "bottom", "left", "right" (default: "bottom")

custom_threshold

(numeric) Option to specify a custom starting point instead of axis

...

other arguments passed to the function

Examples

library(lattice)
data(mtcars)
mtcars$car <- rownames(mtcars)

xyplot(mpg ~ factor(car, car[order(mpg)]), mtcars[1:10, ],
  pch = 19, xlab = "", lwd = 2,
  scales = list(x = list(rot = 35)),
  panel = function(x, y, ...) {
    panel.lollipop(x, y, ...)
  }
)

# with grouping, and lollipops hanging from top
xyplot(mpg ~ factor(car, car[order(mpg)]), mtcars[1:10, ],
  groups = gear, pch = 19, xlab = "", lwd = 2,
  scales = list(x = list(rot = 35)),
  panel = function(x, y, ...) {
    panel.lollipop(x, y, origin = "top", ...)
  }
)


m-jahn/lattice-tools documentation built on Dec. 3, 2023, 11:14 p.m.