stat-qq-line
Q-Q reference-line statistic: two endpoints of the IQR-fitted line.
Slope is (q3 - q1) / (t3 - t1) from the sample’s 25th and 75th type-7 quantiles divided by the corresponding theoretical quantiles of the reference distribution, and intercept is q1 - slope * t1. Endpoints span the theoretical range that stat-qq would emit for the same n and reference distribution. Supported reference distributions are "normal" (default), "uniform", and "exponential".
Usage
stat-qq-line()Returns
Statistic object with name: "qq-line", consumed by geom layers.
Outputs
theoretical.sample.
Examples
Reference line under geom-qq for a normal Q-Q plot.
#let d = (1, 2, 3, 4, 5).map(v => (v: v))
#plot(
data: d,
mapping: aes(y: "v"),
layers: (geom-qq(), geom-qq-line()),
width: 10cm,
height: 6cm,
)Constructor form: stat: stat-qq-line() is equivalent to stat: "qq-line" with defaults.
#let d = range(1, 21).map(i => (v: i + calc.sin(i)))
#plot(
data: d,
mapping: aes(y: "v"),
layers: (
geom-qq(size: 2pt),
geom-line(stat: stat-qq-line(), stroke: 1pt, colour: rgb("#cc0000")),
),
width: 10cm,
height: 6cm,
)