scale-fill-viridis-b

Binned viridis fill scale.

Partitions the continuous domain into n-breaks equal segments, each coloured from the chosen viridis palette.

Usage

scale-fill-viridis-b(
  option,
  n-breaks,
  name,
  limits,
  oob,
  labels,
)

Parameters

Parameter Default Description
option Palette name: "viridis", "magma", "plasma", "inferno", or "cividis".
n-breaks Number of bins to partition the domain into.
name Legend title. Overrides any name set via labs 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

Default viridis ramp quantised into four bins for a banded fill.

#let d = range(0, 12).map(i => (grp: str(i), y: i + 1))
#plot(
  data: d,
  mapping: aes(x: "grp", y: "y", fill: "y"),
  layers: (geom-col(),),
  scales: (scale-fill-viridis-b(n-breaks: 4),),
  width: 10cm,
  height: 6cm,
)

Bar chart of twelve increasing bars where y is cut into four stepped bands coloured along the viridis ramp from purple to yellow.

Bar chart of twelve increasing bars where y is cut into four stepped bands coloured along the viridis ramp from purple to yellow.

The same ramp shown as a banded swatch via geom-rect.

#let d = range(0, 12).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-viridis-b(option: "plasma", n-breaks: 6),),
  guides: guides(fill: none),
  theme: theme-void(),
  width: 8cm,
  height: 1cm,
)

Colour-bar swatch of twelve rectangles where z is cut into six stepped bands coloured from the plasma viridis palette ranging purple through pink to yellow.

Colour-bar swatch of twelve rectangles where z is cut into six stepped bands coloured from the plasma viridis palette ranging purple through pink to yellow.

See also

scale-fill-viridis-c, scale-fill-viridis-d, scale-colour-viridis-b.

Back to top