scale-fill-continuous

Continuous fill scale mapping a numeric column to fill colours.

Usage

scale-fill-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 ramp filling bars by their numeric value.

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

Bar chart of three bars a, b, c filled along the default continuous viridis ramp from dark purple at low y to bright yellow at high y.

Bar chart of three bars a, b, c filled along the default continuous viridis ramp from dark purple at low y to bright yellow at high y.

The default ramp shown as a continuous swatch via geom-rect over a sampled gradient.

#let d = range(0, 16).map(i => (
  xmin: i, xmax: i + 1, ymin: 0, ymax: 1, z: i,
))
#plot(
  data: d,
  mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "z"),
  layers: (geom-rect(),),
  scales: (scale-fill-continuous(),),
  guides: guides(fill: none),
  theme: theme-void(),
  width: 10cm,
  height: 1cm,
)

Colour-bar swatch of sixteen rectangles displaying the default continuous viridis fill ramp from dark purple on the left to bright yellow on the right.

Colour-bar swatch of sixteen rectangles displaying the default continuous viridis fill ramp from dark purple on the left to bright yellow on the right.

See also

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

Back to top