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) ~ AxesParameters
| Name | Type | Description |
|---|---|---|
| px | Float | pixel x |
| py | Float | pixel y |
Return
| Type | Description |
|---|---|
| Axes | the 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() ~ AxesReturn
| Type | Description |
|---|---|
| Axes | the axes |
GetAxes #
One axes of a subplot grid.
method : public : GetAxes(row:Int, col:Int) ~ AxesParameters
| Name | Type | Description |
|---|---|---|
| row | Int | row from 0 |
| col | Int | column from 0 |
Return
| Type | Description |
|---|---|
| Axes | the axes |
New # constructor
Constructor: a figure with a single Axes.
New(width:Int, height:Int)Parameters
| Name | Type | Description |
|---|---|---|
| width | Int | width in pixels, at least 200 |
| height | Int | height in pixels, at least 150 |
Save #
Writes the SVG to a file.
method : public : Save(path:String) ~ BoolParameters
| Name | Type | Description |
|---|---|---|
| path | String | file to write |
Return
| Type | Description |
|---|---|
| Bool | true when written |
SetTitle #
Sets a title above all the axes.
method : public : SetTitle(title:String) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| title | String | the text |
Subplots #
Replaces the axes with a rows x cols grid, left to right, top to bottom.
method : public : Subplots(rows:Int, cols:Int) ~ NilParameters
| Name | Type | Description |
|---|---|---|
| rows | Int | number of rows, 1 to 8 |
| cols | Int | number of columns, 1 to 8 |