scales
Bind scale specifications to aesthetics.
Accepts named arguments where each key is an aesthetic (e.g., x, colour, fill) and each value is a scale spec from a scale-* constructor, or auto to keep the default scale. The resulting dictionary threads into the plot spec and is honoured by scale training. When two entries target the same aesthetic the later one wins, matching guides.
Usage
scales(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Named scale specs keyed by aesthetic name. |
Keys accepted by ..args:
x: a scale spec for thexaesthetic, orautofor the default.y: a scale spec for theyaesthetic, orautofor the default.colour: a scale spec for thecolouraesthetic, orautofor the default.fill: a scale spec for thefillaesthetic, orautofor the default.size: a scale spec for thesizeaesthetic, orautofor the default.alpha: a scale spec for thealphaaesthetic, orautofor the default.linewidth: a scale spec for thelinewidthaesthetic, orautofor the default.stroke: a scale spec for thestrokeaesthetic, orautofor the default.shape: a scale spec for theshapeaesthetic, orautofor the default.linetype: a scale spec for thelinetypeaesthetic, orautofor the default.
Returns
Dictionary mapping aesthetic name to scale spec.
Examples
Pin the x domain and colour the points with a discrete viridis palette in one keyed call.
#let d = (
(x: 1, y: 1, g: "a"),
(x: 2, y: 2, g: "b"),
(x: 3, y: 3, g: "c"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "g"),
layers: (geom-point(size: 3pt),),
scales: scales(
x: scale-continuous(limits: (0, 4)),
colour: scale-viridis-d(),
),
width: 10cm,
height: 6cm,
)