scale-y-log10

Continuous y scale on a base-10 log axis.

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

Usage

scale-y-log10(
  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

Log-10 y axis turns an exponential into a near-linear shape.

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

Scatter chart of ten exponential values where a log10 y axis straightens the curve into evenly spaced points climbing the panel.

Scatter chart of ten exponential values where a log10 y axis straightens the curve into evenly spaced points climbing the panel.

Combine limits and breaks to clip and label a specific log range.

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

Scatter chart of exponential values on a log10 y axis clipped to 2 through 1024 with breaks pinned at 2, 8, 32, 128, 512 for tidy labelling.

Scatter chart of exponential values on a log10 y axis clipped to 2 through 1024 with breaks pinned at 2, 8, 32, 128, 512 for tidy labelling.

See also

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

Back to top