geom-qq

Q-Q point layer: sorted sample versus theoretical quantile.

The sample aesthetic selects the column to compare against the chosen reference distribution. When sample is absent the layer falls back to y so simple aes(y: ...) plots also work. Colour, fill, shape, and alpha can be set or mapped through aes.

Usage

geom-qq(
  mapping: none,
  data: none,
  size: auto,
  stroke: auto,
  fill: auto,
  colour: auto,
  alpha: auto,
  shape: 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.
size auto Marker size (a Typst length).
stroke auto Marker outline thickness (a Typst length) or stroke dictionary; none disables the outline and the colour aesthetic.
fill auto Marker fill colour. auto resolves via the colour scale or a neutral default.
colour auto Fixed marker outline colour. auto resolves via the colour scale, falling back to the theme ink. Only takes effect when stroke is non-zero.
alpha auto Marker opacity in [0, 1].
shape auto Marker shape keyword. auto honours the shape 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

Simple Q-Q against a normal reference, mapping y only.

#let d = (1, 2, 3, 4, 5).map(v => (v: v))
#plot(
  data: d,
  mapping: aes(y: "v"),
  layers: (geom-qq(),),
  width: 10cm,
  height: 6cm,
)

Q-Q plot of five values v showing sample quantiles on y against theoretical normal quantiles on x as points.

Q-Q plot of five values v showing sample quantiles on y against theoretical normal quantiles on x as points.

Switch distribution to "uniform" to compare against a different reference.

#let d = range(1, 21).map(i => (v: i))
#plot(
  data: d,
  mapping: aes(y: "v"),
  layers: (geom-qq(distribution: "uniform"),),
  width: 10cm,
  height: 6cm,
)

Q-Q plot of 20 integer values v against theoretical uniform quantiles showing a near-straight diagonal of points.

Q-Q plot of 20 integer values v against theoretical uniform quantiles showing a near-straight diagonal of points.

See also

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

Back to top