scale-colour-viridis-d

Discrete viridis colour scale.

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

Usage

scale-colour-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 labels 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

Plasma option of the viridis family applied to four categories.

#let d = (
  (x: 1, y: 2, sp: "a"),
  (x: 2, y: 4, sp: "b"),
  (x: 3, y: 3, sp: "c"),
  (x: 4, y: 5, sp: "d"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "sp"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-colour-viridis-d(option: "plasma"),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of four points where sp maps to distinct categorical colours sampled from the plasma viridis palette ranging from purple to yellow.

Scatter chart of four points where sp maps to distinct categorical colours sampled from the plasma viridis palette ranging from purple to yellow.

Switching option to "cividis" selects the colour-blind safe alternative.

#let d = (
  (x: 1, y: 2, sp: "a"),
  (x: 2, y: 4, sp: "b"),
  (x: 3, y: 3, sp: "c"),
  (x: 4, y: 5, sp: "d"),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: "sp"),
  layers: (geom-point(size: 3pt),),
  scales: (scale-colour-viridis-d(option: "cividis"),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of four points where sp maps to colours sampled from the colour-blind safe cividis palette running from dark blue to bright yellow.

Scatter chart of four points where sp maps to colours sampled from the colour-blind safe cividis palette running from dark blue to bright yellow.

See also

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

Back to top