scale-fill-viridis-d

Discrete viridis fill scale.

option selects between "viridis", "magma", "plasma", "inferno", and "cividis".

Usage

scale-fill-viridis-d(
  option,
  name,
  limits,
  oob,
  labels,
)

Parameters

Parameter Default Description
option Palette name: "viridis", "magma", "plasma", "inferno", or "cividis".
name Legend title. Overrides any name set via labs when both are present.
limits Array of level names controlling order and inclusion, 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 limits, or auto.

Returns

Scale object consumed by plot.

Examples

Cividis option filling four categorical bars.

#let d = (
  (grp: "a", y: 1),
  (grp: "b", y: 2),
  (grp: "c", y: 3),
  (grp: "d", y: 4),
)
#plot(
  data: d,
  mapping: aes(x: "grp", y: "y", fill: "grp"),
  layers: (geom-col(),),
  scales: (scale-fill-viridis-d(option: "cividis"),),
  width: 10cm,
  height: 6cm,
)

Bar chart of four bars a, b, c, d filled with distinct colours sampled from the colour-blind safe cividis palette ranging dark blue to yellow.

Bar chart of four bars a, b, c, d filled with distinct colours sampled from the colour-blind safe cividis palette ranging dark blue to yellow.

Each viridis option laid out as a swatch strip via geom-rect.

#let opts = ("viridis", "magma", "plasma", "inferno", "cividis")
#let d = opts.enumerate().map(((i, k)) => (
  xmin: i, xmax: i + 1, ymin: 0, ymax: 1, k: k,
))
#plot(
  data: d,
  mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "k"),
  layers: (geom-rect(),),
  scales: (scale-fill-viridis-d(option: "magma"),),
  guides: guides(fill: none),
  theme: theme-void(),
  width: 6cm,
  height: 1cm,
)

Legend swatch strip of five rectangles filled with distinct colours sampled from the magma viridis palette spanning black through red to pale cream.

Legend swatch strip of five rectangles filled with distinct colours sampled from the magma viridis palette spanning black through red to pale cream.

See also

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

Back to top