scale-colour-grey

Discrete grey colour scale.

Generates n evenly-spaced luma colours from start (darker) to end (lighter), each in [0, 1] where 0 is black and 1 is white.

Usage

scale-colour-grey(
  start,
  end,
  name,
  limits,
  oob,
  labels,
)

Parameters

Parameter Default Description
start Luminance for the first level, in [0, 1].
end Luminance for the last level, in [0, 1].
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

Default grey ramp from dark to light spread across three levels.

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

Scatter chart of three points where sp maps to three evenly-spaced grey luma values stepping from dark grey to light grey.

Scatter chart of three points where sp maps to three evenly-spaced grey luma values stepping from dark grey to light grey.

Narrowing start and end constrains the ramp to a darker range for tighter contrast.

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

Scatter chart of three points where sp maps to a narrowed grey ramp from luma 0.1 to 0.5, keeping the palette in the darker half of the scale.

Scatter chart of three points where sp maps to a narrowed grey ramp from luma 0.1 to 0.5, keeping the palette in the darker half of the scale.

See also

scale-fill-grey, scale-colour-discrete.

Back to top