scale-viridis-d

Discrete viridis colour/fill scale.

option selects "viridis", "magma", "plasma", "inferno", or "cividis".

Usage

scale-viridis-d(
  ..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".
  • name: Axis or legend title, as a string or content; none (default) falls back to the mapped column name.
  • limits: Array of level names selecting which levels appear and in which order; none (default) keeps the trained levels. A level name must be a string, because a discrete scale reads a bare number as a position rather than as a level, so quote a numeric level as "1".
  • oob: Handling of rows whose level falls outside limits: "drop" (default) removes them; "squish" censors too, since clamping has no meaning on levels.
  • labels: Array of labels in level order, a function of the level returning a string or content, or auto (default) to print the level itself.

Returns

Deferred scale spec consumed by scales.

Examples

Colour three groups with a discrete viridis palette.

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

Scatter chart of three points coloured by group with the discrete viridis palette.

Scatter chart of three points coloured by group with the discrete viridis palette.

See also

scales, scale-viridis-c, scale-viridis-b.

Back to top