geom-linerange

Linerange layer: one vertical line from ymin to ymax at each x.

Mapping must provide x, ymin, ymax. Colour and linetype may be mapped or set as fixed layer parameters.

Usage

geom-linerange(
  mapping: none,
  data: none,
  stroke: 0.8pt,
  colour: auto,
  alpha: auto,
  linetype: "solid",
  stat: "identity",
  position: "identity",
  inherit-aes: true,
)

Parameters

Parameter Default Description
mapping none Layer-specific aesthetic mapping built with aes. Must map x, ymin, ymax.
data none Layer-specific dataset. Falls back to the plot data when none.
stroke 0.8pt Line thickness (a Typst length).
colour auto Fixed line colour. auto resolves via the colour scale.
alpha auto Line opacity in [0, 1].
linetype "solid" Dash keyword. Defaults to "solid".
stat "identity" Statistical transform name. Usually "identity".
position "identity" Position adjustment name. Usually "identity".
inherit-aes true Whether to merge the plot-level mapping into this layer’s mapping.

Returns

Layer dictionary consumed by plot.

Examples

Bare vertical ranges, no end caps.

#let d = range(1, 6).map(i => (
  x: i,
  lo: i - 0.5,
  hi: i + 0.5,
))
#plot(
  data: d,
  mapping: aes(x: "x", ymin: "lo", ymax: "hi"),
  layers: (geom-linerange(stroke: 1pt),),
  width: 10cm,
  height: 6cm,
)

Five vertical line ranges at x = 1 to 5 spanning lo to hi on the y axis with no end caps.

Five vertical line ranges at x = 1 to 5 spanning lo to hi on the y axis with no end caps.

Map colour to a categorical column to differentiate ranges per group.

#let d = range(1, 6).map(i => (
  x: i, lo: i - 0.5, hi: i + 0.5,
  k: if calc.rem(i, 2) == 0 { "even" } else { "odd" },
))
#plot(
  data: d,
  mapping: aes(x: "x", ymin: "lo", ymax: "hi", colour: "k"),
  layers: (geom-linerange(stroke: 1.2pt),),
  width: 10cm,
  height: 6cm,
)

Five vertical line ranges at x = 1 to 5 spanning lo to hi on y coloured by even/odd category via the colour aesthetic.

Five vertical line ranges at x = 1 to 5 spanning lo to hi on y coloured by even/odd category via the colour aesthetic.

See also

geom-errorbar, geom-pointrange.

Back to top