geom-quantile
Quantile-regression layer: a fitted line per requested τ.
Default quantiles are (0.25, 0.5, 0.75). The lines are drawn through geom-line on top of the stat’s grouped output. Set colour per layer to colour all lines uniformly; for per-quantile colour, map an aesthetic to the _quantile column emitted by the stat.
Usage
geom-quantile(
mapping: none,
data: none,
quantiles: (0.25, 0.5, 0.75),
n-samples: 64,
stroke: 0.6pt,
colour: auto,
alpha: auto,
linetype: auto,
linewidth: auto,
position: "identity",
inherit-aes: true,
)Parameters
| Parameter | Default | Description |
|---|---|---|
mapping |
none |
Layer-specific aesthetic mapping built with aes. Falls back to the plot mapping when none. |
data |
none |
Layer-specific dataset. Falls back to the plot data when none. |
quantiles |
(0.25, 0.5, 0.75) |
Array of τ values in (0, 1) to fit. |
n-samples |
64 |
Number of evenly-spaced x positions sampled per fitted line. |
stroke |
0.6pt |
Line thickness (a Typst length). |
colour |
auto |
Fixed line colour. auto resolves via the colour scale or a neutral default. |
alpha |
auto |
Line opacity in [0, 1]. |
linetype |
auto |
Dash keyword. auto honours the linetype scale. |
linewidth |
auto |
Multiplier on line thickness, mapped via the linewidth scale. |
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
Median plus quartile bands over a noisy linear trend.
#let d = range(0, 50).map(i => (
x: i,
y: i * 0.5 + calc.sin(i * 0.4) * 4,
))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (
geom-point(size: 2pt, alpha: 0.4),
geom-quantile(),
),
width: 10cm,
height: 6cm,
)