scale-fill-fermenter

Binned ColorBrewer fill scale.

Fill counterpart of scale-colour-fermenter.

Usage

scale-fill-fermenter(
  palette,
  n-breaks,
  breaks,
  direction,
  name,
  limits,
  oob,
  labels,
)

Parameters

Parameter Default Description
palette ColorBrewer palette name (sequential or diverging works best).
n-breaks Number of bins to partition the domain into. Ignored when breaks is set.
breaks Array of bin edges, or auto to derive equal-width bins from n-breaks. Edges define the bin boundaries; n-breaks is ignored when set.
direction 1 for canonical order, -1 for reversed.
name Legend title. Overrides any name set via labels when both are present.
limits Pair (lo, hi) clipping the trained domain, or none.
oob Out-of-range policy: "drop" (default) removes rows whose value falls outside limits; "squish" clamps continuous values to the nearest endpoint.
labels Array of legend labels aligned with the bins, or auto.

Returns

Scale object consumed by plot.

Examples

Spectral palette quantised into five bins, shown as a swatch via geom-rect.

#let d = range(0, 16).map(i => (
  xmin: i, xmax: i + 1, ymin: 0, ymax: 1, z: i,
))
#plot(
  data: d,
  mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "z"),
  layers: (geom-rect(),),
  scales: (scale-fill-fermenter(palette: "Spectral", n-breaks: 5),),
  guides: guides(fill: none),
  theme: theme-void(),
  width: 10cm,
  height: 1cm,
)

Colour-bar swatch of sixteen rectangles displaying the ColorBrewer Spectral palette cut into five stepped fill bands from red through yellow to blue.

Colour-bar swatch of sixteen rectangles displaying the ColorBrewer Spectral palette cut into five stepped fill bands from red through yellow to blue.

See also

scale-colour-fermenter, scale-fill-distiller.

Back to top