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".

PlotAxis

One resolved axis: its range (on the log10 scale when logarithmic), tick step and, for a categorical axis, the names.

Operations

GetHi #

Top of the range, as an exponent when logarithmic.

method : public : GetHi() ~ Float

Return

TypeDescription
Floatthe high end

GetLo #

Bottom of the range, as an exponent when logarithmic.

method : public : GetLo() ~ Float

Return

TypeDescription
Floatthe low end

IsCategorical #

Whether the axis is categorical (names at 0, 1, 2, ...), which does not zoom.

method : public : IsCategorical() ~ Bool

Return

TypeDescription
Booltrue when it has names

IsLog #

Whether the axis is logarithmic.

method : public : IsLog() ~ Bool

Return

TypeDescription
Booltrue for log

Label #

The label of a tick.

method : public : Label(v:Float) ~ String

Parameters

NameTypeDescription
vFloata value from Ticks

Return

TypeDescription
Stringtext

New # constructor

Constructor

New(log:Bool, lo:Float, hi:Float, step:Float, names:String[])

Parameters

NameTypeDescription
logBooltrue for a base-10 log axis; lo and hi are then exponents
loFloatbottom of the range
hiFloattop of the range, above lo
stepFloattick step (ignored for log and categorical axes)
namesStringcategory names, or Nil

Pos #

Where a data value falls on the axis.

method : public : Pos(v:Float) ~ Float

Parameters

NameTypeDescription
vFloatthe data value (positive on a log axis)

Return

TypeDescription
Float0 at the low end, 1 at the high end

Shifted #

The data range after moving the view along the axis.

method : public : Shifted(fraction:Float) ~ Float[]

Parameters

NameTypeDescription
fractionFloathow far to move, as a fraction of the visible range; positive moves toward the high end

Return

TypeDescription
Float[low, high] in data space

Ticks #

Tick values in data space.

method : public : Ticks() ~ Float[]

Return

TypeDescription
Floatthe ticks

Value #

The data value at a position on the axis; the inverse of Pos.

method : public : Value(f:Float) ~ Float

Parameters

NameTypeDescription
fFloat0 at the low end, 1 at the high end

Return

TypeDescription
Floatthe data value

Zoomed #

The data range after zooming about a position on the axis; a log axis zooms in log space, so a decade stays a decade.

method : public : Zoomed(f:Float, factor:Float) ~ Float[]

Parameters

NameTypeDescription
fFloatwhere the zoom is anchored: 0 at the low end, 1 at the high end
factorFloatabove 1 zooms in, below 1 zooms out

Return

TypeDescription
Float[low, high] in data space