scale-x-log10

Continuous x scale on a base-10 log axis.

Thin wrapper over scale-x-continuous with transform: "log10". All x values must be strictly positive.

Usage

scale-x-log10(
  name: none,
  limits: none,
  oob: "drop",
  breaks: auto,
  minor-breaks: auto,
  n-minor: auto,
  labels: auto,
)

Parameters

Parameter Default Description
name none Axis title. Overrides any name set via labels when both are present.
limits none Pair (lo, hi) clipping the trained domain, or none for automatic limits. Either element may be auto to keep the trained bound on that side.
oob "drop" Out-of-range policy: "drop" (default) removes rows whose value falls outside limits; "squish" clamps them to the nearest endpoint.
breaks auto Array of break values, or auto for automatic tick selection.
minor-breaks auto Array of minor gridline positions, or auto to derive them automatically (midpoints between major breaks, extended one step beyond each end).
n-minor auto Number of minor gridlines between adjacent major breaks when minor-breaks is auto; auto resolves to 1.
labels auto Array of tick labels aligned with breaks, or auto.

Returns

Scale object consumed by plot.

Examples

Log-10 axis with auto breaks across several decades of x.

#let d = range(1, 11).map(i => (x: calc.pow(10, i / 2), y: i))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  scales: (scale-x-log10(name: "x"),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of ten points climbing a log10 x axis whose auto breaks place tidy decade ticks across several orders of magnitude.

Scatter chart of ten points climbing a log10 x axis whose auto breaks place tidy decade ticks across several orders of magnitude.

Pin tick positions explicitly for tidier labelling on a known log range.

#let d = range(1, 11).map(i => (x: calc.pow(10, i / 2), y: i))
#plot(
  data: d,
  mapping: aes(x: "x", y: "y"),
  layers: (geom-point(size: 2pt),),
  scales: (scale-x-log10(
    name: "x",
    breaks: (1, 10, 100, 1000, 10000),
  ),),
  width: 10cm,
  height: 6cm,
)

Scatter chart of ten points on a log10 x axis with breaks pinned at 1, 10, 100, 1000, 10000 for tidy decade labelling.

Scatter chart of ten points on a log10 x axis with breaks pinned at 1, 10, 100, 1000, 10000 for tidy decade labelling.

See also

scale-x-continuous, scale-y-log10.

Back to top