scale-fill-brewer

Discrete ColorBrewer fill scale.

Fill counterpart of scale-colour-brewer. Same palette names apply.

Usage

scale-fill-brewer(
  ..args,
)

Parameters

Parameter Default Description
..args

Returns

Scale object consumed by plot.

Examples

Set1 palette filling categorical bars.

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

Bar chart of three bars a, b, c filled with bold qualitative red, blue, green hues sampled from the ColorBrewer Set1 palette.

Bar chart of three bars a, b, c filled with bold qualitative red, blue, green hues sampled from the ColorBrewer Set1 palette.

The Spectral palette laid out as a swatch strip via geom-rect.

#let levels = ("a", "b", "c", "d", "e", "f", "g")
#let d = levels.enumerate().map(((i, k)) => (
  xmin: i, xmax: i + 1, ymin: 0, ymax: 1, k: k,
))
#plot(
  data: d,
  mapping: aes(xmin: "xmin", xmax: "xmax", ymin: "ymin", ymax: "ymax", fill: "k"),
  layers: (geom-rect(),),
  scales: (scale-fill-brewer(palette: "Spectral"),),
  guides: guides(fill: guide-none()),
  width: 8cm,
  height: 1cm,
)

Legend swatch strip of seven rectangles displaying the diverging Spectral ColorBrewer palette from red through yellow at midpoint to blue.

Legend swatch strip of seven rectangles displaying the diverging Spectral ColorBrewer palette from red through yellow at midpoint to blue.

See also

scale-colour-brewer, scale-fill-discrete.

Back to top