scale-linetype
Discrete linetype scale: maps levels to dash-pattern keywords.
Pass a custom array of keywords via palette to override the default linetype set.
Usage
scale-linetype(
name: none,
palette: auto,
limits: none,
labels: auto,
)Parameters
| Parameter | Default | Description |
|---|---|---|
name |
none |
Legend title. Overrides any name set via labs when both are present. |
palette |
auto |
Array of dash keywords, or auto for the library default. |
limits |
none |
Array of level names controlling order and inclusion, or none. |
labels |
auto |
Array of legend labels aligned with limits, or auto. |
Returns
Scale object consumed by plot.
Examples
Default linetype palette mapping two groups to distinct dash patterns.
#let d = (
(x: 1, y: 2, grp: "a"),
(x: 2, y: 4, grp: "a"),
(x: 3, y: 3, grp: "a"),
(x: 1, y: 1, grp: "b"),
(x: 2, y: 2, grp: "b"),
(x: 3, y: 4, grp: "b"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", linetype: "grp"),
layers: (geom-line(stroke: 1pt),),
scales: (scale-linetype(),),
width: 10cm,
height: 6cm,
)Override palette with a custom keyword cycle.
#let d = (
(x: 1, y: 2, grp: "a"), (x: 2, y: 4, grp: "a"),
(x: 1, y: 1, grp: "b"), (x: 2, y: 2, grp: "b"),
)
#plot(
data: d,
mapping: aes(x: "x", y: "y", linetype: "grp"),
layers: (geom-line(stroke: 1pt),),
scales: (scale-linetype(palette: ("dotted", "dash-dotted")),),
width: 10cm,
height: 6cm,
)