geom-linerange
Linerange layer: one vertical line from ymin to ymax at each x.
Since 0.0.1.
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: auto,
colour: auto,
alpha: auto,
linetype: auto,
stat: "identity",
position: "identity",
key: auto,
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, or a function applied to the plot data returning the layer frame. Falls back to the plot data when none. |
stroke |
auto |
Line thickness (a Typst length). |
colour |
auto |
Fixed line colour. auto resolves via the colour scale. |
alpha |
auto |
Line opacity in [0, 1]. |
linetype |
auto |
Dash keyword (e.g., "solid", "dashed"). auto honours the linetype scale. |
stat |
"identity" |
Statistical transform name. Usually "identity". |
position |
"identity" |
Position adjustment name. Usually "identity". |
key |
auto |
Legend glyph override built with a draw-key-* helper. auto picks the default for the geom. |
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,
)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,
)