Plotting
graph
Creates a new plotting canvas: graph() for defaults, graph(w, h) for a size in pixels with the range fitted to what is plotted, graph(xmin, xmax, ymin, ymax) sized automatically from the data range, or graph(w, h, xmin, xmax, ymin, ymax) with explicit pixel dimensions.
xmin (number) -- optional
xmax (number) -- optional
ymin (number) -- optional
ymax (number) -- optional
title
Sets a graph's title.
g (graph) --
text (string) --
xticks
Sets a graph's x-axis tick spacing.
g (graph) --
spacing (number) --
yticks
Sets a graph's y-axis tick spacing.
g (graph) --
spacing (number) --
plot
Adds a line series to a graph: plot(g, ys) auto-indexes x = 1..n, plot(g, xs, ys) uses an explicit x array, or plot(g, "expr", min, max) samples an expression in x over a range. Optional trailing color/linetype/label style args.
g (graph) --
data (number[] | string) -- an array, two arrays, or a quoted expression in x
style (string) -- optional color, linetype, label
axes
Shows or hides a graph's axes.
g (graph) --
show (boolean) -- true or false
grid
Shows or hides a graph's grid lines.
g (graph) --
show (boolean) -- true or false
aspect
Forces a graph's x and y axes to use equal pixels-per-unit scaling, so geometric shapes aren't visually distorted.
g (graph) --
equal (boolean) -- true or false
tracePlot Apas Cloud
Makes the curves of a graph draw themselves in: each line traces from the start of its range to the end (x for plot, t for plotParametric, theta for plotPolar) over the given number of seconds, with a dot at the moving end. Leave the seconds out for 4; at most 60; 0 turns it off. On a page the reader can click the picture to play it again. SVG, PNG and PDF output show the finished curves. One-line form: tracePlot(g, "expr", min, max, seconds, color, linetype, label) plots the function and traces it in one call; tracePolar and traceParametric do the same for the other two kinds of curve. All curves of one graph draw together, over the time given last.
g (graph) --
seconds (number) -- how long the drawing takes; optional, 4 if left out
tracePolar Apas Cloud
plotPolar and tracePlot in one line: adds the polar curve r(theta) to the graph and makes the graph's curves draw themselves in over the given number of seconds (4 if left out, at most 60). The optional color, line type and label follow the seconds, as in plotPolar.
g (graph) --
rExpr (string) -- r as an expression in theta
thetaMin (number) --
thetaMax (number) --
seconds (number) -- how long the drawing takes; optional
traceParametric Apas Cloud
plotParametric and tracePlot in one line: adds the curve (x(t), y(t)) to the graph and makes the graph's curves draw themselves in over the given number of seconds (4 if left out, at most 60). The optional color, line type and label follow the seconds, as in plotParametric.
g (graph) --
xExpr (string) -- x as an expression in t
yExpr (string) -- y as an expression in t
tmin (number) --
tmax (number) --
seconds (number) -- how long the drawing takes; optional
plotParametric
Adds a parametric curve series (x(t), y(t)) to a graph, sampled over an explicit t range.
g (graph) --
xExpr (string) -- expression in t
yExpr (string) -- expression in t
tmin (number) --
tmax (number) --
plotPolar
Adds a polar curve series r(theta) to a graph, sampled over an explicit theta range.
g (graph) --
rExpr (string) -- expression in theta
thetaMin (number) --
thetaMax (number) --
scatter
Adds a scatter (points only, no line) series to a graph: scatter(g, ys) auto-indexes x, scatter(g, xs, ys) uses an explicit x array.
g (graph) --
xs (number[]) -- optional explicit x array
ys (number[]) --
bar
Adds a bar series to a graph: bar(g, ys) auto-indexes x, bar(g, xs, ys) uses an explicit x array. When xs is a list of names, bar(g, ["Mon", "Tue"], ys), each bar is named on the x axis and drawn as a thin bar with a rounded end. Several bar series on one graph are told apart by colour and label; stacked(g) stands them on one another.
g (graph) --
xs (number[] or text[]) -- optional: the x of each bar, or a name for each bar
ys (number[]) --
stacked
Stands the bar series of a graph on one another instead of one in front of the other: at each x the first series is at the bottom and each later one starts where the one before it ends. Values above zero stack upwards and values below zero downwards. stacked(g, false) turns it off again.
g (graph) --
on (boolean) -- optional, true when left out
pie
Draws values as parts of a whole: pie(g, names, values) gives one slice for each value, starting at twelve o'clock and going clockwise, with each name, value and share listed beside it. A fourth argument between 0 and 1 leaves a hole of that part of the radius, which makes a ring. A list of colours, one for each slice, may be given last. The values must be zero or more, with at least one above zero.
g (graph) --
names (text[]) -- a name for each slice
values (number[]) -- the size of each slice
hole (number) -- optional, 0 up to but not 1
colors (text[]) -- optional, a colour for each slice
area
Adds a filled-area line series (filled to y=0) to a graph.
g (graph) --
xs (number[]) --
ys (number[]) --
bubble
Adds a bubble series to a graph -- a scatter plot where a third array sets each point's marker size.
g (graph) --
xs (number[]) --
ys (number[]) --
sizes (number[]) --
histogram
Bins raw data into equal-width buckets and adds it to a graph as a bar series.
g (graph) --
data (number[]) -- raw values to bin
numBins (number) -- optional, defaults to 10
candlestick
Adds a candlestick (OHLC) series to a graph, typically indexed by date().
g (graph) --
xs (number[]) -- typically date() values
opens (number[]) --
highs (number[]) --
lows (number[]) --
closes (number[]) --
logScale
Switches a graph's x, y, or both axes to a logarithmic scale.
g (graph) --
axis (string) -- "x", "y", or "both"