stat-contour-filled

Filled iso-band statistic. Partitions the (x, y, z) field into bands defined by successive levels and emits one closed polygon per cell that touches each band. Pair with geom-polygon or geom-contour-filled.

bins, binwidth, and breaks follow stat-contour precedence, but with one extra level so neighbouring lines bound n + 1 bands (i.e., bins: 10 produces ~11 levels and 10 bands).

Usage

stat-contour-filled(
  bins: 10,
  binwidth: none,
  breaks: auto,
)

Parameters

Parameter Default Description
bins 10 Target band count when breaks and binwidth are unset.
binwidth none Fixed step between successive levels. Overrides bins.
breaks auto Explicit array of level boundaries. Overrides the rest.

Returns

Statistic object with name: "contour_filled".

Outputs

  • x.
  • y.
  • group.
  • _level.

Examples

Drive geom-polygon with the constructor form to fill eight iso-bands of sin(x) * cos(y) and paint them via the viridis palette.

#let n = 30
#let d = ()
#for i in range(n) { for j in range(n) {
  let x = -3 + 6 * i / (n - 1)
  let y = -3 + 6 * j / (n - 1)
  d.push((x: x, y: y, z: calc.sin(x) * calc.cos(y)))
} }
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", z: "z"),
  layers: (geom-polygon(stat: stat-contour-filled(bins: 8)),),
  scales: (scale-fill-viridis-c(),),
  width: 10cm,
  height: 6cm,
)

Eight filled iso-bands of sin(x)*cos(y) over a 30-by-30 grid spanning x and y from -3 to 3 painted by level via stat-contour-filled and the viridis fill palette.

Eight filled iso-bands of sin(x)*cos(y) over a 30-by-30 grid spanning x and y from -3 to 3 painted by level via stat-contour-filled and the viridis fill palette.

See also

geom-contour-filled, stat-contour.

Back to top