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() ~ FloatReturn
| Type | Description |
|---|---|
| Float | the high end |
GetLo #
Bottom of the range, as an exponent when logarithmic.
method : public : GetLo() ~ FloatReturn
| Type | Description |
|---|---|
| Float | the low end |
IsCategorical #
Whether the axis is categorical (names at 0, 1, 2, ...), which does not zoom.
method : public : IsCategorical() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true when it has names |
IsLog #
Whether the axis is logarithmic.
method : public : IsLog() ~ BoolReturn
| Type | Description |
|---|---|
| Bool | true for log |
Label #
The label of a tick.
method : public : Label(v:Float) ~ StringParameters
| Name | Type | Description |
|---|---|---|
| v | Float | a value from Ticks |
Return
| Type | Description |
|---|---|
| String | text |
New # constructor
Constructor
New(log:Bool, lo:Float, hi:Float, step:Float, names:String[])Parameters
| Name | Type | Description |
|---|---|---|
| log | Bool | true for a base-10 log axis; lo and hi are then exponents |
| lo | Float | bottom of the range |
| hi | Float | top of the range, above lo |
| step | Float | tick step (ignored for log and categorical axes) |
| names | String | category names, or Nil |
Pos #
Where a data value falls on the axis.
method : public : Pos(v:Float) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| v | Float | the data value (positive on a log axis) |
Return
| Type | Description |
|---|---|
| Float | 0 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
| Name | Type | Description |
|---|---|---|
| fraction | Float | how far to move, as a fraction of the visible range; positive moves toward the high end |
Return
| Type | Description |
|---|---|
| Float | [low, high] in data space |
Ticks #
Tick values in data space.
method : public : Ticks() ~ Float[]Return
| Type | Description |
|---|---|
| Float | the ticks |
Value #
The data value at a position on the axis; the inverse of Pos.
method : public : Value(f:Float) ~ FloatParameters
| Name | Type | Description |
|---|---|---|
| f | Float | 0 at the low end, 1 at the high end |
Return
| Type | Description |
|---|---|
| Float | the 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
| Name | Type | Description |
|---|---|---|
| f | Float | where the zoom is anchored: 0 at the low end, 1 at the high end |
| factor | Float | above 1 zooms in, below 1 zooms out |
Return
| Type | Description |
|---|---|
| Float | [low, high] in data space |