scale-fill-steps2

Binned diverging fill gradient through a midpoint.

Fill counterpart of scale-colour-steps2.

Usage

scale-fill-steps2(
  low,
  mid,
  high,
  midpoint,
  n-breaks,
  breaks,
  name,
  limits,
  oob,
  labels,
)

Parameters

Parameter Default Description
low Colour for values far below midpoint.
mid Colour at midpoint.
high Colour for values far above midpoint.
midpoint Value at which the palette transitions through mid.
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.
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

Six-bin diverging swatch pivoting at zero.

#let d = range(-7, 8).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-steps2(midpoint: 0, n-breaks: 6),),
  guides: guides(fill: none),
  theme: theme-void(),
  width: 10cm,
  height: 1cm,
)

Colour-bar swatch of fifteen rectangles displaying a diverging fill ramp cut into six stepped bands pivoting through white at zero, green-toned for negative and red for positive.

Colour-bar swatch of fifteen rectangles displaying a diverging fill ramp cut into six stepped bands pivoting through white at zero, green-toned for negative and red for positive.

See also

scale-colour-steps2, scale-fill-steps, scale-fill-stepsn.

Back to top