Skip to main content

fraction

lq.tick-format.fraction(ticks, simplify: true, simplify-integers: true, suffix: none, suffix-position: "outside", omit-unity: true, tick-info: (:), ..args)(source)

Formats linear ticks (see tick-locate.linear) with automatic fractions when the tick distance is a fraction of 1.

#lq.diagram(
xlim: (-0.5, 1),
xaxis: (
tick-distance: 1 / 4,
format-ticks: lq.tick-format.fraction
)
)

A suffix like π\pi can be inserted for π\pi-based scales, see also tick-locate.linear.

#lq.diagram(
xlim: (-calc.pi / 2, calc.pi),
xaxis: (
tick-distance: 1 / 4,
locate-ticks: lq.tick-locate.linear.with(unit: calc.pi),
format-ticks: lq.tick-format.fraction.with(suffix: $pi$)
)
)
Parameters

ticks : array

The ticks to format.

simplify : bool    default: true

Whether to simplify fractions, like 2/42/4 to 1/21/2.

simplify-integers : bool    default: true

Whether to simplify integers − like 4/24/2 to 22 − and show no fraction.

suffix : content    default: none

A suffix to display with each tick label, except with 0.

suffix-position : "outside" | "numerator"    default: "outside"

Whether to place the suffix in the numerator or outside the fraction.

omit-unity : bool    default: true

Whether to omit 11 and 1-1 in combination with a suffix, e.g., π-\pi instead of 1π-1\pi.

tick-info : dictionary    default: (:)

Additional information from the tick locator.

..args : any

Arguments that are ignored by this formatter.