scale-colour-continuous

Continuous colour scale mapping a numeric column to stroke colours.

Usage

scale-colour-continuous(
  name,
  palette,
  limits,
  oob,
  breaks,
  labels,
)

Parameters

Parameter Default Description
name Legend title. Overrides any name set via labels when both are present.
palette Colour source: a gradient, an array of colours, or auto.
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.
breaks Array of break values for the legend, or auto.
labels Array of legend labels aligned with breaks, or auto.

Returns

Scale object consumed by plot.

Examples

Default viridis ramp interpolating across the library’s continuous palette.

#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-continuous(),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points coloured by z along the default continuous viridis ramp from dark purple at low values to bright yellow at high values.

Scatter chart of twelve diagonal points coloured by z along the default continuous viridis ramp from dark purple at low values to bright yellow at high values.

Pin limits to clip the trained domain and render extremes at the palette endpoints.

#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-continuous(limits: (1, 4)),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of twelve diagonal points coloured by z along the continuous viridis ramp, with limits 1 through 4 clamping out-of-range values to palette endpoints.

Scatter chart of twelve diagonal points coloured by z along the continuous viridis ramp, with limits 1 through 4 clamping out-of-range values to palette endpoints.

See also

scale-colour-viridis-c, scale-colour-discrete, scale-fill-continuous.

Back to top