geom-contour-filled

Filled iso-band layer: marching-squares cell clipping over a regular (x, y, z) grid. Pair with a continuous fill scale on _level to shade each band by its lower bound.

Default stroke: none so adjacent cell polygons tile seamlessly. Set stroke explicitly to outline every cell, which is rarely useful unless you want to inspect the partition.

Usage

geom-contour-filled(
  mapping: none,
  data: none,
  bins: 10,
  binwidth: none,
  breaks: auto,
  colour: auto,
  fill: auto,
  stroke: none,
  alpha: auto,
  inherit-aes: true,
)

Parameters

Parameter Default Description
mapping none Layer-specific aesthetic mapping built with aes. Must map x, y, and z.
data none Layer-specific dataset. Falls back to the plot data when none.
bins 10 Target band count.
binwidth none Fixed step between successive levels. Overrides bins.
breaks auto Explicit array of level boundaries. Overrides the rest.
colour auto Cell outline colour. Honoured only when stroke is set.
fill auto Cell fill colour. auto lets the fill scale paint by _level.
stroke none Outline thickness or stroke dictionary. Defaults to none.
alpha auto Cell opacity in [0, 1].
inherit-aes true Whether to merge the plot-level mapping into this layer’s mapping.

Returns

Layer dictionary consumed by plot.

Examples

Ten bands on a radial-wave field, shaded by level.

#let n = 50
#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-contour-filled(bins: 10),),
  scales: (scale-fill-viridis-c(),),
  width: 11cm,
  height: 7cm,
)

Filled contour bands over x and y from -3 to 3 of a sin(x) * cos(y) field shaded by level via viridis fill.

Filled contour bands over x and y from -3 to 3 of a sin(x) * cos(y) field shaded by level via viridis fill.

See also

stat-contour-filled, geom-contour.

Back to top