scale-fill-identity

Fill scale that uses each row’s value as the fill colour directly.

Values must be hex strings or color values; see scale-colour-identity.

Usage

scale-fill-identity(
  ..args,
)

Parameters

Parameter Default Description
..args

Returns

Scale object consumed by plot.

Examples

Per-row hex strings used as fills, with geom-rect drawing a custom swatch from arbitrary colours.

#let d = (
  (xmin: 0, xmax: 1, ymin: 0, ymax: 1, c: "#1b9e77"),
  (xmin: 1, xmax: 2, ymin: 0, ymax: 1, c: "#d95f02"),
  (xmin: 2, xmax: 3, ymin: 0, ymax: 1, c: "#7570b3"),
)
#plot(
  data: d,
  mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "c"),
  layers: (geom-rect(),),
  scales: (scale-fill-identity(),),
  width: 6cm,
  height: 1cm,
)

Legend swatch strip of three rectangles where the c column passes through hex strings verbatim, filling teal, orange, and lavender bands with no legend.

Legend swatch strip of three rectangles where the c column passes through hex strings verbatim, filling teal, orange, and lavender bands with no legend.

See also

scale-fill-manual, scale-colour-identity.

Back to top