scale-fill-gradient

Continuous two-stop fill gradient.

Fill counterpart of scale-colour-gradient.

Usage

scale-fill-gradient(
  low,
  high,
  name,
  limits,
  oob,
  breaks,
  labels,
)

Parameters

Parameter Default Description
low Colour for the low end of the domain.
high Colour for the high end of the domain.
name Legend title. Overrides any name set via labels when both are present.
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

Custom two-stop ramp shown as a continuous swatch via geom-rect.

#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-gradient(
    low: rgb("#fee5d9"),
    high: rgb("#a50f15"),
  ),),
  guides: guides(fill: none),
  theme: theme-void(),
  width: 10cm,
  height: 1cm,
)

Colour-bar swatch of sixteen rectangles displaying a continuous two-stop fill gradient from pale peach on the left to deep crimson on the right.

Colour-bar swatch of sixteen rectangles displaying a continuous two-stop fill gradient from pale peach on the left to deep crimson on the right.

See also

scale-colour-gradient, scale-fill-gradient2, scale-fill-gradientn.

Back to top