stat-boxplot
Boxplot statistic: per-x five-number summary with outlier list.
One output row per distinct x value with keys (x, lower, middle, upper, ymin, ymax, outliers). lower, middle, and upper are the quartiles of the input y values; ymin and ymax are the smallest and largest y still inside the 1.5 × IQR fence; values outside the fence land in outliers.
Usage
stat-boxplot(
coefficient: 1.5,
)Parameters
| Parameter | Default | Description |
|---|---|---|
coefficient |
1.5 |
Whisker length as a multiple of the inter-quartile range. |
Returns
Statistic object with name: "boxplot", consumed by geom layers.
Outputs
x.lower.middle.upper.ymin.ymax.whisker-lo.whisker-hi.outliers.
Examples
Default 1.5 × IQR whisker rule on grouped raw observations.
#let d = ()
#for grp in ("a", "b", "c") {
for i in range(20) {
d.push((grp: grp, y: calc.sin(i) + i / 10))
}
}
#plot(
data: d,
mapping: aes(x: "grp", y: "y"),
layers: (geom-boxplot(),),
width: 10cm,
height: 6cm,
)stat: "boxplot" is equivalent to stat: stat-boxplot() with the default coefficient: 1.5. Use the constructor to customise the whisker length, e.g., stat: stat-boxplot(coefficient: 1.0) tightens the fence so more values surface as outliers.
#let d = ()
#for grp in ("a", "b", "c") {
for i in range(20) {
d.push((grp: grp, y: calc.sin(i) + i / 10))
}
}
#plot(
data: d,
mapping: aes(x: "grp", y: "y"),
layers: (geom-boxplot(stat: stat-boxplot(coefficient: 1.0)),),
width: 10cm,
height: 6cm,
)