scale-reverse

Position scale with the axis direction reversed (x or y).

Tick labels stay in data units; only the axis direction flips.

Usage

scale-reverse(
  ..args,
)

Parameters

Parameter Default Description
..args Named arguments forwarded to the axis scale (e.g. name, limits, breaks, minor-breaks, n-minor, labels).

Returns

Deferred scale spec consumed by scales.

Examples

Reverse the y axis so larger values sit at the bottom.

#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: scales(y: scale-reverse(name: "Rank")),
  width: 10cm,
  height: 6cm,
)

Scatter chart of ten diagonal points on a reversed y axis where larger values sit at the bottom while tick labels stay in data units.

Scatter chart of ten diagonal points on a reversed y axis where larger values sit at the bottom while tick labels stay in data units.

See also

scales, scale-continuous.

Back to top