dup-axis
Duplicate the primary axis on the opposite side of the panel.
Draws the same ticks as the primary axis but on the top edge for x or the right edge for y, optionally with a different title.
Usage
dup-axis(
name: none,
breaks: auto,
labels: auto,
)Parameters
| Parameter | Default | Description |
|---|---|---|
name |
none |
Title shown above or beside the secondary axis, or none. |
breaks |
auto |
Array of break values, or auto to mirror the primary axis. |
labels |
auto |
Array of labels aligned with breaks, or auto. |
Returns
Secondary axis dictionary consumed by scale-x-continuous and scale-y-continuous.
Examples
Mirror the x axis on top with a different title.
#let d = range(0, 11).map(i => (x: i, y: i * i))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
scales: (
scale-x-continuous(name: "x", secondary: dup-axis(name: "x'")),
),
width: 10cm,
height: 6cm,
)Mirror the y axis on the right with custom break positions.
#let d = range(0, 11).map(i => (x: i, y: i * i))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
scales: (
scale-y-continuous(
name: "y",
secondary: dup-axis(breaks: (0, 25, 50, 75, 100)),
),
),
width: 10cm,
height: 6cm,
)