scale-colour-viridis-b

Binned viridis colour scale.

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

Usage

scale-colour-viridis-b(
  option,
  n-breaks,
  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. 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

Four equal-width bins coloured from the default viridis ramp.

#let d = range(0, 12).map(i => (x: i, y: i, z: i * 0.5))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "z"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-colour-viridis-b(n-breaks: 4),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points where z is cut into four stepped bands coloured from the viridis ramp running purple to yellow.

Scatter chart of twelve diagonal points where z is cut into four stepped bands coloured from the viridis ramp running purple to yellow.

Bumping n-breaks and switching to the inferno option produces a finer-grained banded scale.

#let d = range(0, 12).map(i => (x: i, y: i, z: i * 0.5))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "z"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-colour-viridis-b(option: "inferno", n-breaks: 8),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points where z is cut into eight finer stepped bands coloured from the inferno ramp running black through red to bright yellow.

Scatter chart of twelve diagonal points where z is cut into eight finer stepped bands coloured from the inferno ramp running black through red to bright yellow.

See also

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

Back to top