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

PlotPrimitive

One drawing primitive in pixel space. Colors are CSS strings such as "#1f77b4"; an empty string means none. Which fields are meaningful depends on the kind: LINE uses x1, y1, x2, y2; POLYLINE and POLYGON use the x, y pairs of GetPoints(); RECT uses x1, y1 as the corner and x2, y2 as the width and height; CIRCLE uses x1, y1 as the center and x2 as the radius; TEXT uses x1, y1 as the anchor point; CLIP_BEGIN uses the same corner, width and height as RECT and clips what follows until the matching CLIP_END.

Operations

GetAnchor #

Text anchor.

method : public : GetAnchor() ~ TextAnchor

Return

TypeDescription
TextAnchorwhere the text sits relative to x

GetDash #

Dash pattern.

method : public : GetDash() ~ String

Return

TypeDescription
Stringan SVG dash array such as "4 3", or an empty string for solid

GetFill #

Fill color, or the text color.

method : public : GetFill() ~ String

Return

TypeDescription
Stringa CSS color, or an empty string for none

GetKind #

What the primitive draws.

method : public : GetKind() ~ PrimitiveKind

Return

TypeDescription
PrimitiveKindthe kind

GetOpacity #

Fill opacity.

method : public : GetOpacity() ~ Float

Return

TypeDescription
Float0 to 1

GetPoints #

The x, y pairs of a polyline or polygon.

method : public : GetPoints() ~ Float[]

Return

TypeDescription
Floatalternating x and y, or Nil

GetRotation #

Text rotation about the anchor.

method : public : GetRotation() ~ Float

Return

TypeDescription
Floatdegrees, counter-clockwise negative as in SVG

GetSize #

Text size.

method : public : GetSize() ~ Int

Return

TypeDescription
Intpixels

GetStroke #

Outline color.

method : public : GetStroke() ~ String

Return

TypeDescription
Stringa CSS color, or an empty string for none

GetTag #

What the primitive is: marker, bar, grid, tick, legend, and so on.

method : public : GetTag() ~ String

Return

TypeDescription
Stringthe tag

GetText #

The string of a text primitive.

method : public : GetText() ~ String

Return

TypeDescription
Stringthe text

GetWidth #

Stroke width.

method : public : GetWidth() ~ Float

Return

TypeDescription
Floatpixels

GetX1 #

First x, the corner or center x or the text anchor x.

method : public : GetX1() ~ Float

Return

TypeDescription
Floatx

GetX2 #

Second x of a line, the width of a rect or the radius of a circle.

method : public : GetX2() ~ Float

Return

TypeDescription
Floatthe value

GetY1 #

First y.

method : public : GetY1() ~ Float

Return

TypeDescription
Floaty

GetY2 #

Second y of a line or the height of a rect.

method : public : GetY2() ~ Float

Return

TypeDescription
Floatthe value

IsBold #

Whether text is bold.

method : public : IsBold() ~ Bool

Return

TypeDescription
Booltrue for bold

New # constructor

Constructor; PlotScene builds primitives, so most programs never call it.

New(kind:PrimitiveKind, x1:Float, y1:Float, x2:Float, y2:Float, points:Float[], stroke:String, fill:String, width:Float, opacity:Float, text:String, anchor:TextAnchor, size:Int, bold:Bool, rotation:Float, dash:String, tag:String)

Parameters

NameTypeDescription
kindPrimitiveKindwhat to draw
x1Floatfirst x
y1Floatfirst y
x2Floatsecond x, or width, or radius
y2Floatsecond y or height
pointsFloatx, y pairs for a polyline or polygon, or Nil
strokeStringoutline color, or empty
fillStringfill color, or empty
widthFloatstroke width in pixels
opacityFloatfill opacity from 0 to 1
textStringthe string of a text primitive
anchorTextAnchortext anchor
sizeInttext size in pixels
boldBooltrue for bold text
rotationFloattext rotation in degrees about its anchor
dashStringSVG dash pattern such as "4 3", or empty
tagStringwhat the primitive is (marker, bar, grid, ...), for tests and backends