guides
Bind guide specifications to aesthetics.
Accepts named arguments where each key is an aesthetic (e.g., colour, fill) and each value is a guide spec from guide-legend, none to hide that guide, or auto for the default. The resulting dictionary threads into the plot spec and is honoured by the legend renderer. For the x / y axes, none hides the axis ticks and tick labels (the axis line and title stay; remove the title with labels(x: none)); under coord-radial, theta / r none hide the angular / radial axis labels while the spokes and circles stay.
Usage
guides(
..args,
)Parameters
| Parameter | Default | Description |
|---|---|---|
..args |
Named guide specs keyed by aesthetic name. |
Keys accepted by ..args:
colour: a guide spec fromguide-legendfor thecolouraesthetic,noneto hide it, orautofor the default.fill: a guide spec fromguide-legendfor thefillaesthetic,noneto hide it, orautofor the default.size: a guide spec fromguide-legendfor thesizeaesthetic,noneto hide it, orautofor the default.alpha: a guide spec fromguide-legendfor thealphaaesthetic,noneto hide it, orautofor the default.linewidth: a guide spec fromguide-legendfor thelinewidthaesthetic,noneto hide it, orautofor the default.shape: a guide spec fromguide-legendfor theshapeaesthetic,noneto hide it, orautofor the default.linetype: a guide spec fromguide-legendfor thelinetypeaesthetic,noneto hide it, orautofor the default.stroke: a guide spec fromguide-legendfor thestrokeaesthetic,noneto hide it, orautofor the default.x: a guide spec fromguide-legendfor thexaesthetic,noneto hide it, orautofor the default.y: a guide spec fromguide-legendfor theyaesthetic,noneto hide it, orautofor the default.theta: a guide spec fromguide-legendfor thethetaaesthetic,noneto hide it, orautofor the default.r: a guide spec fromguide-legendfor theraesthetic,noneto hide it, orautofor the default.default: a fallback guide whose unset fields (e.g. anautoposition) are inherited by every aesthetic without its own override, soguides(default: guide-legend(position: "bottom"))moves all legends to the bottom in one call;guides(default: none)hides every legend that has no override of its own.
Returns
Dictionary mapping aesthetic name to guide spec.
Examples
Lay the colour legend out across two columns.
#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),),
guides: guides(colour: guide-legend(ncolumn: 2)),
width: 10cm,
height: 6cm,
)Combine guide-axis and none to rotate x ticks and hide the redundant fill legend in one call.
#let d = (
(x: "January", y: 1, g: "a"),
(x: "February", y: 2, g: "a"),
(x: "March", y: 3, g: "b"),
(x: "April", y: 4, g: "b"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", fill: "g"),
layers: (geom-col(),),
guides: guides(
x: guide-axis(angle: 30),
fill: none,
),
width: 10cm,
height: 6cm,
)Use default to place every legend at the bottom in one call; the per-aesthetic colour override inherits that side and only changes its column count.
#let d = (
(x: 1, y: 1, g: "a", s: "p"),
(x: 2, y: 2, g: "b", s: "q"),
(x: 3, y: 3, g: "c", s: "p"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", colour: "g", shape: "s"),
layers: (geom-point(size: 3pt),),
guides: guides(
default: guide-legend(position: "bottom"),
colour: guide-legend(ncolumn: 3),
),
width: 9cm,
height: 6cm,
)