scale-x-continuous
Continuous x scale: axis title, limits, breaks, labels, and transformation.
transform accepts "identity", "log10", "sqrt", and "reverse".
Usage
scale-x-continuous(
name: none,
limits: none,
breaks: auto,
labels: auto,
transform: "identity",
expand: auto,
secondary: none,
)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. |
transform |
"identity" |
Transformation keyword: "identity", "log10", "sqrt", or "reverse". |
expand |
auto |
Padding around the domain. Accepts a ratio (5%) for proportional breathing room, a length (5pt) for canvas-space padding, a relative (5pt + 5%) for both, or a (lo, hi) 2-tuple for asymmetric padding. auto keeps the per-scale default; false collapses to zero. |
secondary |
none |
Secondary axis spec from dup-axis or sec-axis, or none. |
Returns
Scale object consumed by plot.
Examples
Override the axis title and pin the domain.
#let d = range(1, 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: "Index", limits: (0, 12)),),
width: 10cm,
height: 6cm,
)Switch transform to "sqrt" and supply explicit breaks for a custom non-linear axis.
#let d = range(0, 11).map(i => (x: i * i, y: i))
#plot(
data: d,
mapping: aes(x: "x", y: "y"),
layers: (geom-point(size: 2pt),),
scales: (scale-x-continuous(
name: "x (sqrt)",
transform: "sqrt",
breaks: (0, 25, 50, 75, 100),
),),
width: 10cm,
height: 6cm,
)Apply format-comma() to format penguin body-mass tick labels with thousands separators on the x axis.
#plot(
data: penguins,
mapping: aes(x: "body-mass", y: "flipper-len", fill: "species"),
layers: (geom-point(size: 2pt),),
scales: (scale-x-continuous(name: "Body mass (g)", labels: format-comma()),),
width: 11cm,
height: 6cm,
)