scale-viridis-b

Binned viridis colour/fill scale.

Usage

scale-viridis-b(
  ..args,
)

Parameters

Parameter Default Description
..args Named arguments forwarded to the colour/fill scale.

Keys accepted by ..args:

  • option: Viridis variant: "viridis" (default), "magma", "plasma", "inferno", or "cividis".
  • n-breaks: Integer number of equal-width bins used when breaks is auto; default 5.
  • breaks: Array of bin edges, a function of the trained values returning edges (the breaks-* helpers return such a function), ticked at the bin midpoints and overriding n-breaks, or auto (default) to cut n-breaks equal-width bins.
  • name: Axis or legend title, as a string or content; none (default) falls back to the mapped column name.
  • limits: Domain as a (lo, hi) pair, where either side may be auto to train that side from the data; none (default) trains both sides.
  • oob: Handling of rows outside limits: "drop" (default) removes them, "squish" clamps them to the nearest limit.
  • labels: Array of labels aligned with the breaks, a function of the break value returning a string or content (the format-* helpers return such a function), or auto (default) to format each break.

Returns

Deferred scale spec consumed by scales.

Examples

Bin a numeric column onto a stepped viridis fill.

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

Scatter chart of twelve diagonal points whose fill steps through four binned viridis bands.

Scatter chart of twelve diagonal points whose fill steps through four binned viridis bands.

See also

scales, scale-viridis-c, scale-steps.

Back to top