geom-errorbarh

Horizontal errorbar layer: range with a vertical cap at each end.

Mapping must provide y, xmin, xmax. The height parameter sets the cap span in y data units for continuous y, and as a fraction of the per-category slot height for discrete y.

Usage

geom-errorbarh(
  mapping: none,
  data: none,
  height: 0.4,
  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 y, xmin, xmax.
data none Layer-specific dataset. Falls back to the plot data when none.
height 0.4 Cap span. A Typst length sets the cap span directly in panel units; a number is interpreted as y data units for continuous y and a fraction of the slot height for discrete y.
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

Horizontal error bars across an integer y axis.

#let d = range(1, 6).map(i => (
  y: i,
  lo: i - 0.5,
  hi: i + 0.5,
))
#plot(
  data: d,
  mapping: aes(y: "y", xmin: "lo", xmax: "hi"),
  layers: (geom-errorbarh(height: 0.4),),
  width: 10cm,
  height: 6cm,
)

Horizontal errorbars at y = 1 to 5 spanning lo to hi on the x axis with vertical caps at each end.

Horizontal errorbars at y = 1 to 5 spanning lo to hi on the x axis with vertical caps at each end.

Combine with geom-point at the central estimate to show point estimates with horizontal uncertainty.

#let d = range(1, 6).map(i => (
  x: i, y: i, lo: i - 0.5, hi: i + 0.5,
))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", xmin: "lo", xmax: "hi"),
  layers: (
    geom-errorbarh(height: 0.3),
    geom-point(size: 3pt),
  ),
  width: 10cm,
  height: 6cm,
)

Horizontal errorbars from lo to hi at y = 1 to 5 overlaid with point markers at the central x estimate.

Horizontal errorbars from lo to hi at y = 1 to 5 overlaid with point markers at the central x estimate.

See also

geom-errorbar, geom-linerange, geom-pointrange.

Back to top