Plots¶
The plot{} keyword draws an orthogonal coordinate system on its grid, and
plots in it: points, named beside them, the curves of functions, and broken
lines.
As for the other keywords, values are separated by ;, and options follow a
| separator; multiple options are separated by ;.
The values are the points. With no option at all, both axes run from -4 to
4, graduated every unit — the figure mental calculation reads coordinates
on:
The grid is drawn by default: the figure is there to have coordinates read
on it. grid=false leaves it out, and the sub-grid with it, for a figure read
off its axes alone; the cells keep their size, the axes their length. Only the
ticks at the written values are then left to read by: subdivision_marks=true
adds a shorter one at every graduation where no value is written.
plot{(2; 3):A ; (-3; -1):B ; f(x)=0.5x+1 | grid=false ; x_labels_step=2 ; y_labels_step=2 ; subdivision_marks=true}
Points¶
A point is written (x; y), followed by : and its name, then optionally by
: and its colour:
- The two coordinates are separated by
;— as a pupil writes them in French — or by,. A decimal coordinate is written with a dot:(0.4; -0.6). - The name is any atmxg expression;
_(or nothing) marks a point without one. A name holding a:is wrapped in{…}. - The colour defaults to the red mathmaker used (
rendering.plot.point_color);_keeps the default. The name is written in the colour of its point.
A point is marked by a cross, its name set diagonally away from the
origin, so that it stands clear of both axes whatever quadrant it is in.
point_names and point_marks choose which points have their name written
and their cross drawn: true (or all, the default), false (or none),
or a list of names, point_names=A, C. A name naming no point is refused.
Like axis{}, a coordinate is read exactly, and a point must lie
inside the grid that is drawn. It may fall between two lines of the
grid, (2; -1.5) on a grid of units: it is drawn exactly where its
coordinates put it. Whether a figure asks its reader to estimate is up to
whoever writes it, or to the question that generates it.
There may be no point at all: plot{} is an empty system.
Curves¶
A value written f(x)= and an expression is a curve rather than a point:
the graph of that function, drawn across the whole grid. Points and curves
mix freely, separated by ; like any values.
- The name is one letter, followed by
(x). Each function has a letter of its own: two curves calledfare refused, a figure in which f(2) would mean two things — unless they are the pieces of one function, drawn over intervals apart. - The expression is a polynomial, or a quotient of polynomials, written
exactly as a literal expression is typed into an answer box — it is read
by the same parser: numbers,
x,+,-,*(or×,·),/(or÷), powers written^or²,³, and parentheses. Multiplication may be left out —2x,3(x+1),(x+1)(x-2)— a number written afterxis its exponent (x2isx²), and a decimal number takes a comma or a point.1/2xis read as(1/2)x, as an answer box reads it. An exponent is a whole number up to 8. No other letter is read, and no function. - The colon, which divides in an answer box, separates a curve from its
colour here: divide with
/or÷. - An interval may follow the expression,
[0; 4]: see Over an interval. - The colour, after a
:, defaults torendering.plot.curve_color.
The curve is cut where it leaves the grid, and broken where the function has
no value or leaps from one side of the grid to the other between two of the
points it is computed at — an asymptote, as 1/x has about 0, is not a line
to draw.
Over an interval¶
A curve is drawn across the whole grid unless an interval follows its expression, written as in class, before the colour, if any. The curve is then drawn over that interval only:
plot{f(x)=0.5x [0; 4] ; g(x)=2 [4; 8]:#3771c8 ; h(x)=-x+10 [8; 10] | x_min=0 ; x_max=10 ; y_min=0 ; y_max=4}
- The bounds are separated by
;, or by,when there is no;:[0, 4]. Between;, a decimal bound may take a comma:[0,5; 2]. - Either bracket may be open or closed:
[0; 4],]0; 4],[0; 4[,]0; 4[. The curve is drawn up to its bounds either way; the brackets tell where the function has a value (see below). - An infinite bound,
-infor+inf(or∞), takes the curve to the edge of the grid:]-inf; 2],[3; +inf[. Its bracket is always open. - The lower bound must be less than the upper one, and the interval must reach into the grid.
A function in pieces is written with the same letter for each piece:
plot{f(x)=0.5x [0; 4[ ; f(x)=2 [4; 8[ ; f(x)=-x+10 [8; 10] | x_min=0 ; x_max=10 ; y_min=0 ; y_max=4 ; curve_names=true}
The pieces must not overlap: f(2) would mean two things. Two pieces may
share a bound, closed on both sides, only if they give the same value
there: f(x)=0.5x [0; 4] ; f(x)=2 [4; 8] is accepted, since both give
f(4) = 2. Otherwise one of the two brackets must be open. A function in
pieces is named once, by where its rightmost piece ends.
curve_names writes the name of curves — Cf — inside the grid, by where
each one leaves it: true (or all) names every curve, false (or none,
the default) none, and a list of letters names those curves only —
curve_names=f, h. A letter naming no curve of the figure is refused.
Broken lines¶
A value written as names of points joined by - is a broken line: its
segments join the points in the order written. A line going back to its
first point is closed. The colour may follow, after a ::
plot{(1; 1):A ; (5; 1):B ; (4; 4):C ; (2; 3):D ; A-B-C-D-A:#3771c8 | x_min=0 ; x_max=6 ; y_min=0 ; y_max=5 ; point_marks=false}
- A vertex is the name of a point of the figure, as written:
A,A'. A name holding a-is wrapped in{…}, both in the point and in the line. The point may be written before or after the line. - A vertex may also be given by its coordinates,
(0; 2)-(1; 5)-(2; 4), and the two may be mixed:A-(3; 4)-B. Such a vertex is not a point: it has no name and no cross. To mark it, declare it as a point, without a name if need be ((3; 4):_), and name it in the line. - Like a point, a vertex must lie inside the grid.
- A line may come back on itself,
A-C-B-D. It joins two different vertices at least. A line naming no point, or a name that two points share, is refused. - The colour defaults to
rendering.plot.curve_color. The line is drawn under the crosses and the names.
The name of a vertex of a closed line is set away from the centre of the line (the mean of its vertices) rather than from the origin, so that it stands outside the figure.
Bounds and graduation¶
x_min, x_max, y_min and y_max are the last values written on each
axis. The origin must lie between them — a bound may be the origin itself.
How finely an axis is graduated is read off the way its bounds are written.
-4 to 4 is graduated every unit, -1.0 to 1.0 every tenth, -1.00 to
1.00 every hundredth. Where the two bounds of an axis are written with
different decimals, the finer one wins.
The grid is drawn one cell past each bound, so that the written range does not run into the edge of the picture — except past a bound that is the origin: a first-quadrant figure starts where its axes do.
The scale of an axis¶
x_scale and y_scale set instead the value of a cell along an axis — its
scale, as one says one square for ten units. A curve that grows fast is
drawn this way without a hundred cells to the axis:
The cells stay square: what changes is what a cell is worth along that axis,
and so how many of them it takes. Its bounds must be multiples of the scale; the scale must have a decimal writing (10, 0.5,
2.5), the values written along the axis being multiples of it. Left out,
the bounds of an axis given a scale are four cells either side of the origin
— y_scale=10 alone runs from -40 to 40.
Subdivisions¶
x_subdivisions and y_subdivisions cut each cell into that many parts
along their axis, and draw them as a sub-grid, lighter and thinner than
the grid. A cell keeps its value: where y_scale=0.5 makes a cell worth
0.5, and so stretches the axis, y_subdivisions=2 keeps it worth 1 and
draws a line every 0.5 inside it. The figure stays orthonormal.
plot{(2; 1.5):A ; f(x)=0.5x+0.5 | x_min=-1 ; x_max=4 ; y_min=-1 ; y_max=3 ; y_subdivisions=2 ; y_labels_step=0.5}
subdivisionssets both axes at once;x_subdivisionsory_subdivisionsoverrides it for its own axis.- A subdivision is a whole number of parts,
1(the default) meaning none:3cuts a cell into thirds, which no decimal value could. - The values written may then fall on the subdivisions:
y_labels_stepmust be a whole number of them, and have a decimal writing. Left out, the values are written on the grid's lines, as without subdivisions. - It combines with a scale:
y_scale=10 ; y_subdivisions=2draws a cell for10and a sub-grid line every5. subdivision_marks=truedraws a shorter tick across each axis at every graduation, subdivisions included, where no value is written. It is off by default: the sub-grid is enough to count on.
The sub-grid's colour and stroke width are subgrid_color and
subgrid_thickness in the configuration (under rendering.plot), the
length of the shorter ticks sub_tick_len_ratio; each may be overridden for
a single figure by an option of the same name.
Written values¶
x_labels_step and y_labels_step set how often a value is written along
each axis, counted from the origin; each must be a whole number of
graduations. A short tick crosses the axis at every written value. The origin
is written once, as 0, in the corner below and left of the axes.
Left out, the step is the finest of 1, 2, 5, 10, 20… graduations that writes
no more than max_labels values (10 by default) along the axis: every unit
from -4 to 4, but every 0.2 on a grid of tenths from -1.0 to 1.0.
Values are written in the notation of the render locale (0,2 in French),
negative ones with the true minus sign.
show_graduations hides them: false writes no value at all, x or y
those of that axis only, true (the default) both. The ticks stay, so the
graduation can still be counted, and the origin's 0 is written as long as
either axis has its values.
Durations, in hours¶
An axis of durations is graduated in minutes — one cell for 10 min, which no
decimal value of an hour could be. x_hours=true (or y_hours) writes its
values in hours nonetheless, whole hours only: 1, 2, 3 at 60, 120
and 180 min. The coordinates, the bounds and the scale stay in minutes; the
unit belongs in the title of the axis.
plot{(80; 2):A | x_min=0 ; x_max=180 ; x_scale=10 ; x_hours=true ; y_min=0 ; y_max=4 ; x_title=durée (h) ; y_title=distance (km)}
A value is written every hour, or every multiple of an hour that
x_labels_step gives (120 writes every second one). No 1 h 20 is ever
written: a pupil reads it two cells past 1. The hours must fall on
graduations: 60 must be a multiple of the value of a cell, subdivisions
included.
Titles of the axes¶
x_title and y_title say what each axis stands for: x_title is written
past the arrow of the axis of abscissas, y_title above the arrow of the axis
of ordinates. Each is a text, written at the size of the values along the
axes and in their colour; a literal \n starts a new line.
plot{(20; 1.5):A ; (120; 4):B ; A-B | x_min=0 ; x_max=180 ; x_scale=10 ; x_labels_step=30 ; y_min=0 ; y_max=5 ; x_title=durée (min) ; y_title=distance (km)}
A title holding a ; is wrapped in {…}.
Size¶
A cell is cell_size_ratio times the font size, widened where the written
values would otherwise touch — each other, or the 0 of the origin. The
figure is meant to stay small: the default one is about 8.5 times the font
size, in width as in height.
The whole figure is then drawn at a size of its page's kind, set in
rendering.plot: scale by default, overridden by scale_grid,
scale_page or scale_slide where the page is of that kind. A slide sets its
text large enough to be read from the back of the room, and a figure measured
in that text would fill the screen.
Each of those may be overridden in turn on paper or on screen only, by
scale_<kind>_print or scale_<kind>_screen: a printed sheet counts its
height, while a screen is read from further away — scale_grid is 0.7, the
size mathmaker printed its figures at, and scale_grid_screen is 1. The
figure is drawn at its print size, and the page's stylesheet enlarges it on
screen: every dimension of the figure is in em, so it scales as a whole, its
alignment on the line included. A figure shown outside a page — a standalone
automath render svg — keeps its print size.
A screen narrower than 768 px — a phone — takes scale_<kind>_small_screen
instead, where it is set (scale_grid_small_screen is 1): a figure as large
as a computer screen affords would leave no room beside it there. Left out,
the screen size applies to phones too.
A font_size option scales the figure in turn, on top of all that.
Options¶
x_min,x_max,y_min,y_max— the bounds of each axis. Default-4and4. Their decimals set the graduation.x_scale,y_scale— the value of a cell along each axis, instead of the graduation the bounds' decimals give. See The scale of an axis.x_labels_step,y_labels_step— value between two written values. Default: see Written values.show_graduations— which axes have their values written:true(the default),false,xory.max_labels— most values written along an axis whose labels step is not given. Default10.color— colour of the axes and of the values written along them. The grid keepsgrid_color, each point its own colour.x_subdivisions,y_subdivisions,subdivisions— the parts each cell is cut into along that axis (or both), drawn as a sub-grid. Default1, none. See Subdivisions.subdivision_marks—truedraws a shorter tick at every graduation where no value is written. Defaultfalse.grid—false(ornone) leaves out the grid, and the sub-grid. Defaulttrue.grid_color— colour of the grid.cell_size— side of a cell in pixels. Given explicitly, it is honoured as it stands.thickness,grid_thickness— stroke widths of the axes and of the grid.baseline—middleby default: the middle of the figure faces the text beside it.axisputs the axis of abscissas on the text's math axis;topandbottommeasure on the bounding box.font_size— as for the other figures.point_names,point_marks— which points have their name written, and their cross drawn:true(orall, the default),false(ornone), or their names,A, C.x_hours,y_hours—true: the axis counts minutes and writes whole hours. See Durations, in hours.x_title,y_title— what each axis stands for, written past its arrow. See Titles of the axes.curve_names— which curves have their name, Cf, written by where they leave the grid:true(orall),false(ornone, the default), or their letters,f, h.
The cell size, the length of the ticks, the size of what is written, of the
crosses and of the arrowheads, and the gaps around what is written are set
in the configuration (under rendering.plot).
Any of those defaults can be overridden for a single figure by an option of
the same name: cell_size_ratio, tick_len_ratio, label_gap_ratio,
label_spacing_ratio, label_scale, point_mark_ratio,
point_mark_thickness, name_gap_ratio, arrowhead_ratio, subgrid_color,
subgrid_thickness and sub_tick_len_ratio (the *_ratio values are
multiples of the font size).
Examples :
| Expression | Renders as |
|---|---|
plot{(4; -2):W} |
|
plot{(2; 3):B; (5; 1):C:#1F5C99 | x_min=0 ; x_max=6 ; y_min=0 ; y_max=4} |
|
plot{(0.4; -0.6):M | x_min=-1.0 ; x_max=1.0 ; y_min=-1.0 ; y_max=1.0} |
|
plot{(-3; 2):A; (1; -1):_ | x_min=-6 ; x_max=6 ; y_min=-3 ; y_max=3 ; x_labels_step=2} |
|
plot{f(x)=x^2-2 ; g(x)=1/x:#ff950e ; (1; -1):A | curve_names=true} |
|
plot{f(x)=x^2 ; (3; 10):A | x_min=-1 ; x_max=5 ; y_min=0 ; y_max=30 ; y_scale=5 ; label_scale=0.5} |
|
plot{f(x)=0.5x+1 ; g(x)=-x^2+3:#B5251C | show_graduations=false} |
|
plot{f(x)=0.5x [0; 4[ ; f(x)=2 [4; 8[ ; f(x)=-x+10 [8; 10] | x_min=0 ; x_max=10 ; y_min=0 ; y_max=3 ; curve_names=true} |
|
plot{(1; 1):A ; (5; 1):B ; (4; 4):C ; (2; 3):D ; A-B-C-D-A | x_min=0 ; x_max=6 ; y_min=0 ; y_max=5 ; point_marks=false} |
|
plot{(0; 2)-(1; 5)-(2; 4)-(3; 7)-(4; 6):#B5251C | x_min=0 ; x_max=4 ; y_min=0 ; y_max=8} |
|
plot{(2; 1.5):A ; f(x)=0.5x+0.5 | x_min=-1 ; x_max=4 ; y_min=-1 ; y_max=3 ; y_subdivisions=2 ; y_labels_step=0.5} |
|
plot{(20; 1.5):A ; (120; 4):B ; A-B | x_min=0 ; x_max=180 ; x_scale=10 ; x_labels_step=30 ; y_min=0 ; y_max=5 ; x_title=durée (min) ; y_title=distance (km)} |
|
plot{(80; 2):A | x_min=0 ; x_max=180 ; x_scale=10 ; x_hours=true ; y_min=0 ; y_max=4 ; x_title=durée (h) ; y_title=distance (km)} |
|
plot{(2; 3):A ; (-3; -1):B ; f(x)=0.5x+1 | grid=false ; x_labels_step=2 ; y_labels_step=2 ; subdivision_marks=true} |