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

PlotScene

An ordered list of pixel-space primitives: everything a backend needs to draw a figure. Later primitives draw over earlier ones.

Operations

BeginClip #

Starts clipping to a rectangle; everything until EndClip is cut at its edge.

method : public : BeginClip(x:Float, y:Float, width:Float, height:Float) ~ Nil

Parameters

NameTypeDescription
xFloatleft
yFloattop
widthFloatwidth
heightFloatheight

Circle #

Adds a circle.

method : public : Circle(cx:Float, cy:Float, radius:Float, fill:String, stroke:String, opacity:Float, tag:String) ~ Nil

Parameters

NameTypeDescription
cxFloatcenter x
cyFloatcenter y
radiusFloatradius
fillStringfill color, or empty
strokeStringoutline color, or empty
opacityFloatfill opacity
tagStringwhat it is

Count #

Number of primitives carrying a tag.

method : public : Count(tag:String) ~ Int

Parameters

NameTypeDescription
tagStringthe tag, such as "marker"

Return

TypeDescription
Inthow many

EndClip #

Ends the clip started by BeginClip.

method : public : EndClip() ~ Nil

Get #

One primitive.

method : public : Get(index:Int) ~ PlotPrimitive

Parameters

NameTypeDescription
indexIntposition from 0, in drawing order

Return

TypeDescription
PlotPrimitivethe primitive

GetHeight #

Canvas height.

method : public : GetHeight() ~ Int

Return

TypeDescription
Intpixels

GetWidth #

Canvas width.

method : public : GetWidth() ~ Int

Return

TypeDescription
Intpixels

Line #

Adds a straight line.

method : public : Line(x1:Float, y1:Float, x2:Float, y2:Float, stroke:String, width:Float, dash:String, tag:String) ~ Nil

Parameters

NameTypeDescription
x1Floatstart x
y1Floatstart y
x2Floatend x
y2Floatend y
strokeStringcolor
widthFloatstroke width
dashStringdash pattern or empty
tagStringwhat it is

New # constructor

Constructor

New(width:Int, height:Int)

Parameters

NameTypeDescription
widthIntcanvas width in pixels
heightIntcanvas height in pixels

Polygon #

Adds a closed polygon.

method : public : Polygon(points:Float[], fill:String, stroke:String, width:Float, opacity:Float, tag:String) ~ Nil

Parameters

NameTypeDescription
pointsFloatx, y pairs
fillStringfill color, or empty
strokeStringoutline color, or empty
widthFloatstroke width
opacityFloatfill opacity
tagStringwhat it is

Polyline #

Adds an open polyline.

method : public : Polyline(points:Float[], stroke:String, width:Float, tag:String) ~ Nil

Parameters

NameTypeDescription
pointsFloatx, y pairs
strokeStringcolor
widthFloatstroke width
tagStringwhat it is

Rect #

Adds a rectangle.

method : public : Rect(x:Float, y:Float, width:Float, height:Float, fill:String, stroke:String, stroke_width:Float, opacity:Float, tag:String) ~ Nil

Parameters

NameTypeDescription
xFloatleft
yFloattop
widthFloatwidth
heightFloatheight
fillStringfill color, or empty
strokeStringoutline color, or empty
stroke_widthFloatoutline width
opacityFloatfill opacity
tagStringwhat it is

Size #

Number of primitives.

method : public : Size() ~ Int

Return

TypeDescription
Intthe count

Text #

Adds text.

method : public : Text(x:Float, y:Float, text:String, anchor:TextAnchor, size:Int, bold:Bool, fill:String, rotation:Float, tag:String) ~ Nil

Parameters

NameTypeDescription
xFloatanchor x
yFloatbaseline y
textStringthe string
anchorTextAnchorwhere the text sits relative to x
sizeIntsize in pixels
boldBooltrue for bold
fillStringtext color
rotationFloatdegrees about the anchor
tagStringwhat it is