label-wrap
Labeller wrapping long labels onto multiple lines.
Splits the label every width characters, inserting a line break at the nearest preceding space when one exists. Inner labellers may be supplied to first transform the level.
Usage
label-wrap(
width: 20,
inner: none,
)Parameters
| Parameter | Default | Description |
|---|---|---|
width |
20 |
Maximum number of characters per line. |
inner |
none |
Labeller applied before wrapping, or none for the raw level. |
Returns
Labeller dictionary consumed by facet-wrap and facet-grid.
Examples
Wrap long category names onto multiple strip lines.
#let d = (
(sp: "a long category name", x: 1, y: 1),
(sp: "a long category name", x: 2, y: 2),
(sp: "another long one", x: 1, y: 3),
(sp: "another long one", x: 2, y: 4),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
facet: facet-wrap("sp", labeller: label-wrap(width: 10)),
width: 10cm,
height: 5cm,
)Combine inner with label-both to wrap a var: value label.
#let d = (
(sp: "alpha-with-long-suffix", x: 1, y: 1),
(sp: "alpha-with-long-suffix", x: 2, y: 2),
(sp: "beta-with-long-suffix", x: 1, y: 3),
(sp: "beta-with-long-suffix", x: 2, y: 4),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
facet: facet-wrap("sp", labeller: label-wrap(width: 14, inner: label-both())),
width: 10cm,
height: 5cm,
)