from-theme

Pull a value from the resolved theme at render time.

path may be a dotted string ("axis-line.colour") or an array of keys (("axis-line", "colour")). Both forms are equivalent.

from-theme(...) resolves at layer prepare time, so the marker is replaced by a literal scalar before scale training and per-row rendering ever see it. Use it on aesthetic channels that have a fixed-value layer parameter (colour, fill, size, alpha, linewidth, stroke, shape, linetype).

Usage

from-theme(
  path,
)

Parameters

Parameter Default Description
path Dotted string or array of keys naming a theme entry.

Returns

Late-binding marker consumed by aes.

Examples

Pin a layer’s stroke colour to the active theme’s ink.

#let d = (
  (x: 1, y: 2),
  (x: 2, y: 4),
  (x: 3, y: 3),
)
#plot(
  data: d,
  mapping: aes(x: "x", y: "y", colour: from-theme("ink")),
  layers: (geom-point(size: 3pt),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of three points whose marker colour is pinned to the active theme's ink via from-theme.

Scatter chart of three points whose marker colour is pinned to the active theme's ink via from-theme.

See also

aes, theme.

Back to top