Number lines¶
The axis{} keyword draws a graduated number line, with the points marked on
it named above the line.
As for the other keywords, values are separated by ;, and options follow a
| separator; multiple options are separated by ;.
The two values are the first and the last written graduation:
Two families of graduations¶
The main graduations sit every step (1 by default) from the first value
to the last, and carry their value written underneath. The
sub-graduations divide each step into subdivisions equal parts and carry
nothing: they are what the reader counts.
maxi - mini must be a whole number of steps, so that every written
graduation falls on one; axis{0; 3.5 | step=2} is refused rather than drawn
with a last graduation nobody expected.
Past the written range¶
The line is drawn beyond its written range, by before and after
sub-graduations — not units: the margins are counted in the same
graduations as the rest of the axis. after is 2 by default; before is 2
as well, except when the axis starts at the origin, where it is 0 — a line of
positive numbers starts where they do.
Margins are what lets a point be read without the origin on the picture:
Only the graduations between the two written values carry their value. A main graduation falling in a margin is still drawn with the long tick, but stays unwritten — which is how an axis can show the origin without naming it.
Points¶
points marks the points, as a comma-separated list of abscissa:name
pairs. An abscissa may be a whole number, a decimal or a fraction; a name is
any atmxg expression, and _ marks a point without one.
An abscissa is read exactly, as the fraction or the decimal it is written as — never as an approximation — and it must
- fall on a graduation of the axis, and
- lie inside the part of the line that is drawn.
Both are refused rather than approximated: a cross drawn between two
graduations asks its reader to see what is not written. axis{0; 3 |
points=7/4:M} therefore reports that 7/4 falls on no graduation of an axis
graduated every 1, and names the option to set — the mistake is nearly always
a forgotten subdivisions=.
Written values¶
A graduation is written the way the number is: a whole number as it stands, a
decimal in the notation of the render locale (0,5 in French), and a value
with no decimal writing as the fraction it is — a graduation every third of a
unit is written 1/3, never 0,333….
Options¶
step— value between two written graduations. Default1. May be a fraction (step=1/3).subdivisions— how many equal parts each step is divided into. Default1, i.e. no sub-graduation.before,after— sub-graduations drawn past the written range. Default2, and0before an axis that starts at the origin.points— the points marked on the axis:7/4:M, 5/2:B._for a point with no name.arrow—true(default) draws an arrowhead at the right end.length— length of the axis in pixels, first graduation to last. Given explicitly, it is honoured as it stands; left out, it is the configured nominal length, held between a minimum and a maximum spacing per graduation (see below), and widened where the written values would touch.color,thickness,baseline,font_size— as for the other figures.baselineisaxisby default, which puts the line itself on the text's math axis: a wording beside the figure then faces the line rather than the numbers written under it.top,middleandbottommeasure on the bounding box instead.
The nominal length, the two spacings that bound it, the length of the
graduation marks, the size of the crosses and the gaps around what is written
are all set in the
configuration (under rendering.axis). Any of those
defaults can be overridden for a single axis by an option of the same name:
length_ratio, tick_len_ratio, major_tick_len_ratio,
tick_spacing_ratio, max_tick_spacing_ratio, label_gap_ratio,
label_scale, point_mark_ratio,
point_mark_thickness, name_gap_ratio, arrowhead_ratio and
end_gap_ratio (the *_ratio values are multiples of the font size).
length_ratio is what an axis of the usual number of graduations is long,
and the two spacing ratios hold it there. tick_spacing_ratio is the closest
two consecutive graduations may come: the axis is lengthened rather than let
them, because an axis is read by counting its graduations and a comb cannot be
counted. max_tick_spacing_ratio is the widest they may be spread: the axis
is shortened rather than let five graduations take the width of twenty. Either
one is switched off by setting it to 0 — no floor, or no ceiling; set the
floor above the ceiling and the floor wins, a comb being worse than a spread.
Between the two, an axis of few graduations comes out short and one of many
comes out long, which is what makes a page of them look like figures rather
than like one figure redrawn.
label_scale is the size of what is written along the axis, relative to the
text around it — the same convention as a polygon's labels.
Examples :
| Expression | Renders as |
|---|---|
axis{0; 3 | subdivisions=4 ; points=7/4:M} |
|
axis{1; 3 | subdivisions=3 ; before=2 ; points=⅔:M} |
|
axis{0; 1 | step=⅓ ; subdivisions=2 ; points=⅚:M} |
|
axis{0; 2 | step=0.5 ; subdivisions=5 ; points=1.3:A, 1.9:B} |