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) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| x | Float | left |
| y | Float | top |
| width | Float | width |
| height | Float | height |
Circle #
Adds a circle.
method : public : Circle(cx:Float, cy:Float, radius:Float, fill:String, stroke:String, opacity:Float, tag:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| cx | Float | center x |
| cy | Float | center y |
| radius | Float | radius |
| fill | String | fill color, or empty |
| stroke | String | outline color, or empty |
| opacity | Float | fill opacity |
| tag | String | what it is |
Count #
Number of primitives carrying a tag.
method : public : Count(tag:String) ~ IntParameters
| Name | Type | Description |
|---|---|---|
| tag | String | the tag, such as "marker" |
Return
| Type | Description |
|---|---|
| Int | how many |
Get #
One primitive.
method : public : Get(index:Int) ~ PlotPrimitiveParameters
| Name | Type | Description |
|---|---|---|
| index | Int | position from 0, in drawing order |
Return
| Type | Description |
|---|---|
| PlotPrimitive | the primitive |
Line #
Adds a straight line.
method : public : Line(x1:Float, y1:Float, x2:Float, y2:Float, stroke:String, width:Float, dash:String, tag:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| x1 | Float | start x |
| y1 | Float | start y |
| x2 | Float | end x |
| y2 | Float | end y |
| stroke | String | color |
| width | Float | stroke width |
| dash | String | dash pattern or empty |
| tag | String | what it is |
New # constructor
Constructor
New(width:Int, height:Int)Parameters
| Name | Type | Description |
|---|---|---|
| width | Int | canvas width in pixels |
| height | Int | canvas height in pixels |
Polygon #
Adds a closed polygon.
method : public : Polygon(points:Float[], fill:String, stroke:String, width:Float, opacity:Float, tag:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| points | Float | x, y pairs |
| fill | String | fill color, or empty |
| stroke | String | outline color, or empty |
| width | Float | stroke width |
| opacity | Float | fill opacity |
| tag | String | what it is |
Polyline #
Adds an open polyline.
method : public : Polyline(points:Float[], stroke:String, width:Float, tag:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| points | Float | x, y pairs |
| stroke | String | color |
| width | Float | stroke width |
| tag | String | what 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) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| x | Float | left |
| y | Float | top |
| width | Float | width |
| height | Float | height |
| fill | String | fill color, or empty |
| stroke | String | outline color, or empty |
| stroke_width | Float | outline width |
| opacity | Float | fill opacity |
| tag | String | what it is |
Text #
Adds text.
method : public : Text(x:Float, y:Float, text:String, anchor:TextAnchor, size:Int, bold:Bool, fill:String, rotation:Float, tag:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| x | Float | anchor x |
| y | Float | baseline y |
| text | String | the string |
| anchor | TextAnchor | where the text sits relative to x |
| size | Int | size in pixels |
| bold | Bool | true for bold |
| fill | String | text color |
| rotation | Float | degrees about the anchor |
| tag | String | what it is |