Plotting
plot prints a structured record, and the page draws the chart from it. Run a cell to see its output beside the expected one.
plot emits a structured record
figure declares the chart (title, x label, y label) and plot adds a series. Both print records on stdout; the page draws the chart from them and adds nothing of its own.
A matrix as a heatmap with plot2d
plot2d(Z) or plot2d(Z, "label") renders a rank-2 array as a color map (viridis) with a colorbar. The format of the printed record is fixed, and this example's test fails if it changes.
A curve in three dimensions with plot3d
plot3d(x, y, z, "label") draws a rotatable 3-D curve — drag the rendered figure to spin it. Three equal-length rank-1 arrays.
A histogram
histogram counts into equal bins; bars draws the counts at the bin centers. A plot on the same x afterwards draws a curve over the bars, which is how a measured distribution is shown against a theoretical one.
Same x merges into one chart
Consecutive plots sharing an x-array become labeled series on one figure.
Different x means different charts
Each chart gets its own figure.
figure is required
A chart's title and axis labels are part of the program. Nothing outside it can add them, so a plot with no figure declared does not compile — in any engine.
expected error: needs a `figure(title, xlabel, ylabel)` before it…