scale-x-reverse
Continuous x scale flipped left-to-right.
Thin wrapper over scale-x-continuous with transform: "reverse". Tick labels stay in data units; only the axis direction reverses.
Usage
scale-x-reverse(
name: none,
limits: none,
breaks: auto,
labels: auto,
)Parameters
| Parameter | Default | Description |
|---|---|---|
name |
none |
Axis title. Overrides any name set via labs when both are present. |
limits |
none |
Pair (lo, hi) clipping the trained domain, or none for automatic limits. |
breaks |
auto |
Array of break values, or auto for automatic tick selection. |
labels |
auto |
Array of tick labels aligned with breaks, or auto. |
Returns
Scale object consumed by plot.
Examples
Reverse the x axis so values decrease left-to-right.
#let d = range(1, 11).map(i => (x: i, y: i))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
scales: (scale-x-reverse(name: "x"),),
width: 10cm,
height: 6cm,
)Pair with limits to clip a reversed timeline to a specific window.
#let d = range(2000, 2025).map(y => (x: y, y: calc.sin(y / 4)))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-line(stroke: 1pt),),
scales: (scale-x-reverse(name: "Year", limits: (2024, 2010)),),
width: 10cm,
height: 6cm,
)