figure
cheatah-plot v0.1.0-alpha — Biome Standard 0.6.3-alpha
Classes
Axis— One axis: label, transform, limits, and a target tick count.Figure— The whole figure: a rows×cols grid of subplots, pixel size, the categorical palette, and the index fluent calls currently target.Scale— An axis transform choice ("linear" or "log") — a tiny struct instead of an enum, per the house style; make one withlinear()/log_scale().Subplot— One cell of the figure grid: a title, two axes, the series drawn in it, and a legend flag.
Functions
operator<< · 2 overloads
The linear axis transform (the default).
The log10 axis transform (positive data; ticks land on decades via plot.scale.log_ticks).
A fresh default axis: no label, linear, auto limits, 6 ticks — the one place axis defaults live.
A rows×cols grid figure with empty subplots, 900×600 pixels, the tab10 palette, targeting cell 0 — new_figure() is this with a 1×1 grid.
rows | the grid rows (clamped up to at least 1). |
cols | the grid columns (clamped up to at least 1). |
the empty grid Figure.
O(rows·cols).
the Figure and its subplots.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0])
let y = ndarray.array([1.0, 4.0, 2.0])
let f = figure.grid(2, 2)
f = figure.subplot(f, 0, 1)
f = figure.line(f, x, y) # -> the line lands in the top-right cellA fresh single-subplot figure — the usual starting point.
the empty 1×1 Figure.
O(1).
the Figure.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0, 3.0])
let y = ndarray.array([0.0, 1.0, 4.0, 9.0])
let f = figure.new_figure()
f = figure.line(f, x, y) # -> a 1x1 figure holding one line seriesPoint fluent calls at grid cell (r, c) — out-of-range coordinates clamp to the grid.
f | the figure. |
r | the target row (0-based). |
c | the target column (0-based). |
a copy of f targeting that cell.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let data = ndarray.array([1.0, 2.0, 2.0, 3.0, 3.0, 3.0])
let f = figure.grid(1, 2)
f = figure.subplot(f, 0, 1)
f = figure.hist(f, data, 3) # -> the histogram fills the right-hand cellAppend a pre-built series to the targeted subplot — the bridge between the constructor style (series.line(x, y)) and the fluent style.
f | the figure. |
s | the series to append. |
a copy of f with s appended to the current subplot.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import plot.series as series
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0])
let y = ndarray.array([2.0, 1.0, 3.0])
let s = series.scatter(x, y)
let f = figure.new_figure()
f = figure.add(f, s) # -> the pre-built scatter joins the current subplotFigure line(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y)
#
Fluent line mark: append series.line(x, y) to the targeted subplot.
f | the figure. |
x | the x positions. |
y | the y values (same length). |
a copy of f with the line appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0, 3.0])
let y = ndarray.array([0.0, 1.0, 4.0, 9.0])
let f = figure.new_figure()
f = figure.line(f, x, y) # -> one line mark in the single subplotFigure scatter(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y)
#
Fluent scatter mark: append series.scatter(x, y) to the targeted subplot.
f | the figure. |
x | the x positions. |
y | the y values (same length). |
a copy of f with the scatter appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([1.0, 2.0, 3.0, 4.0])
let y = ndarray.array([2.1, 3.9, 6.2, 7.8])
let f = figure.new_figure()
f = figure.scatter(f, x, y) # -> circle markers in the single subplotFigure bar(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y)
#
Fluent bar mark: append series.bar(x, y) to the targeted subplot.
f | the figure. |
x | the bar positions. |
y | the bar heights (same length). |
a copy of f with the bars appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0])
let counts = ndarray.array([4.0, 7.0, 2.0])
let f = figure.new_figure()
f = figure.bar(f, x, counts) # -> three vertical barsFigure area(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y)
#
Fluent area mark: append series.area(x, y) to the targeted subplot.
f | the figure. |
x | the x positions. |
y | the top edge values (same length). |
a copy of f with the area appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0, 3.0])
let y = ndarray.array([0.5, 1.5, 1.0, 2.0])
let f = figure.new_figure()
f = figure.area(f, x, y) # -> the filled area under the curveFigure step(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y)
#
Fluent step mark: append series.step(x, y) to the targeted subplot.
f | the figure. |
x | the x positions. |
y | the y values (same length). |
a copy of f with the step line appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0, 3.0])
let y = ndarray.array([1.0, 3.0, 2.0, 2.5])
let f = figure.new_figure()
f = figure.step(f, x, y) # -> a hold-until-next-x step lineFigure errorbar(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &x, ::cheatah::ndarray::basic_ndarray< double > &y, ::cheatah::ndarray::basic_ndarray< double > &ylo, ::cheatah::ndarray::basic_ndarray< double > &yhi)
#
Fluent error bars: append series.errorbar(x, y, ylo, yhi) to the targeted subplot.
f | the figure. |
x | the x positions. |
y | the central values. |
ylo | the lower whisker ends (absolute). |
yhi | the upper whisker ends (absolute). |
a copy of f with the error bars appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0])
let y = ndarray.array([2.0, 3.0, 2.5])
let ylo = ndarray.array([1.7, 2.6, 2.2])
let yhi = ndarray.array([2.3, 3.4, 2.8])
let f = figure.new_figure()
f = figure.errorbar(f, x, y, ylo, yhi) # -> whiskered points in the subplotFluent heatmap: append series.heatmap(z) to the targeted subplot.
f | the figure. |
z | the row-major 2-D value grid. |
a copy of f with the heatmap appended.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let flat = ndarray.array([1.0, 2.0, 3.0, 4.0, 5.0, 6.0])
let z = ndarray.reshape(flat, [2, 3])
let f = figure.new_figure()
f = figure.heatmap(f, z) # -> the 2x3 grid, coloured by valueFigure hist(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &data, builtins::Value auto &&bins)
#
Fluent histogram: bin data with plot.stats.histogram and append the bars (touching, per histogram convention).
f | the figure. |
data | the samples. |
bins | the bin count (clamped up to at least 1). |
a copy of f with the histogram bars appended.
O(n + bins + figure).
the returned copy plus the histogram arrays.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let data = ndarray.array([1.0, 2.0, 2.0, 3.0, 3.0, 3.0, 4.0])
let f = figure.new_figure()
f = figure.hist(f, data, 4) # -> touching histogram bars over 4 binsSet the targeted subplot's title.
f | the figure. |
t | the title text. |
a copy of f with the title set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
f = figure.title(f, "convergence") # -> the current subplot is titledSet the targeted subplot's x-axis label.
f | the figure. |
s | the label text. |
a copy of f with the label set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
f = figure.xlabel(f, "epoch") # -> the x axis reads "epoch"Set the targeted subplot's y-axis label.
f | the figure. |
s | the label text. |
a copy of f with the label set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
f = figure.ylabel(f, "loss") # -> the y axis reads "loss"Fix the targeted subplot's x limits (overriding auto).
f | the figure. |
lo | the low limit. |
hi | the high limit. |
a copy of f with the limits set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
f = figure.xlim(f, 0.0, 10.0) # -> x spans exactly [0, 10]; auto is overriddenFix the targeted subplot's y limits (overriding auto).
f | the figure. |
lo | the low limit. |
hi | the high limit. |
a copy of f with the limits set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
f = figure.ylim(f, -1.0, 1.0) # -> y pinned to [-1, 1]Set the targeted subplot's x-axis transform.
f | the figure. |
s | the Scale (linear() or log_scale()). |
a copy of f with the transform set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
let s = figure.log_scale()
f = figure.xscale(f, s) # -> decade ticks along xSet the targeted subplot's y-axis transform.
f | the figure. |
s | the Scale (linear() or log_scale()). |
a copy of f with the transform set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
let s = figure.log_scale()
f = figure.yscale(f, s) # -> log10 y; ticks land on decadesTurn the targeted subplot's legend on or off (labeled series get entries when on).
f | the figure. |
on | true to draw the legend box. |
a copy of f with the flag set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
import ndarray
let x = ndarray.array([0.0, 1.0, 2.0])
let y = ndarray.array([1.0, 2.0, 4.0])
let f = figure.new_figure()
f = figure.line(f, x, y)
f = figure.legend(f, true) # -> labeled series get legend entriesSet the figure's pixel size.
f | the figure. |
w | the width in pixels (clamped up to at least 64). |
h | the height in pixels (clamped up to at least 64). |
a copy of f with the size set.
O(figure).
the returned copy.
systests/test_figure.purrimport plot.figure as figure
let f = figure.new_figure()
f = figure.size(f, 1280, 720) # -> a 1280x720 canvasABI/identity marker for the figure cheatah module: returns the module name.
Auto-emitted by purrc's library emitter. It is the concrete symbol that anchors the module's signed static archive in opaque (source-hidden) builds.
the module name ("figure").
