v2026.11.2
All Bundles
Bundle

A matplotlib-like plotting library: scatter, histogram, line and bar charts, subplots, as standalone SVG. A Figure holds one or more Axes; drawing the figure builds a PlotScene, an ordered list of pixel-space drawing primitives (lines, polylines, polygons, rects, circles, text), and a backend turns the scene into output. The SVG backend writes SVG 1.1 with no script and no external font, one decimal for every coordinate, so the same data gives the same bytes on every platform. Compile with -lib plot,gen_collect; it needs nothing else and draws without a display. Design: docs/PLOT_DESIGN.md. Examples: docs/AI.md, "Plotting".

Figure

A canvas of one or more Axes laid out in a grid, with an optional overall title.

Operations

AxesAt #

The axes whose plot area holds a pixel of the last ToScene.

method : public : AxesAt(px:Float, py:Float) ~ Axes

Parameters

NameTypeDescription
pxFloatpixel x
pyFloatpixel y

Return

TypeDescription
Axesthe axes, or Nil when the pixel is outside every plot area

GetAxes #

The first (for a one-plot figure, the only) axes.

method : public : GetAxes() ~ Axes

Return

TypeDescription
Axesthe axes

GetAxes #

One axes of a subplot grid.

method : public : GetAxes(row:Int, col:Int) ~ Axes

Parameters

NameTypeDescription
rowIntrow from 0
colIntcolumn from 0

Return

TypeDescription
Axesthe axes

New # constructor

Constructor: a figure with a single Axes.

New(width:Int, height:Int)

Parameters

NameTypeDescription
widthIntwidth in pixels, at least 200
heightIntheight in pixels, at least 150

Save #

Writes the SVG to a file.

method : public : Save(path:String) ~ Bool

Parameters

NameTypeDescription
pathStringfile to write

Return

TypeDescription
Booltrue when written

SetTitle #

Sets a title above all the axes.

method : public : SetTitle(title:String) ~ Nil

Parameters

NameTypeDescription
titleStringthe text

Subplots #

Replaces the axes with a rows x cols grid, left to right, top to bottom.

method : public : Subplots(rows:Int, cols:Int) ~ Nil

Parameters

NameTypeDescription
rowsIntnumber of rows, 1 to 8
colsIntnumber of columns, 1 to 8

ToScene #

Builds the drawing primitives for the whole figure.

method : public : ToScene() ~ PlotScene

Return

TypeDescription
PlotScenethe scene; raises PlotError when an axes has nothing to draw

ToSvg #

Renders the figure as SVG 1.1.

method : public : ToSvg() ~ String

Return

TypeDescription
Stringthe SVG text