geom-qq-line

Q-Q reference line layer fitted through the IQR of the sample.

The sample aesthetic selects the column whose 25th and 75th quantiles anchor the line; when sample is absent the layer falls back to y. The reference distribution is selected via distribution and must match the matching geom-qq layer.

Usage

geom-qq-line(
  mapping: none,
  data: none,
  stroke: auto,
  colour: auto,
  alpha: auto,
  linetype: auto,
  distribution: "normal",
  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, 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 or a neutral default.
alpha auto Line opacity in [0, 1].
linetype auto Dash keyword. auto honours the linetype scale.
distribution "normal" Reference distribution name; one of "normal" (default), "uniform", "exponential".
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

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,
)

Normal Q-Q plot of v with sample quantiles plotted against theoretical quantiles and a reference line through the IQR.

Normal Q-Q plot of v with sample quantiles plotted against theoretical quantiles and a reference line through the IQR.

Distinguish the line by colour and dash to keep it visible over the points.

#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-qq-line(colour: rgb("#cc0000"), stroke: 1pt, linetype: "dashed"),
  ),
  width: 10cm,
  height: 6cm,
)

Normal Q-Q plot of 20 noisy values with sample quantiles against theoretical and a dashed red reference line through the IQR.

Normal Q-Q plot of 20 noisy values with sample quantiles against theoretical and a dashed red reference line through the IQR.

See also

geom-qq, stat-qq-line, geom-line.

Back to top