cheatah
Module

figure

cheatah-plot v0.1.0-alpha — Biome Standard 0.6.3-alpha

Classes

Functions

fn operator<< · 2 overloads
std::ostream & operator<<(std::ostream &os_, const Scale &v_)#
std::ostream & operator<<(std::ostream &os_, const Axis &v_)#
fn Scale linear() #

The linear axis transform (the default).

Returns

the linear Scale.

Complexity

O(1).

Allocation

the Scale.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
let s = figure.linear()
f = figure.xscale(f, s)   # -> back to the default linear x transform
fn Scale log_scale() #

The log10 axis transform (positive data; ticks land on decades via plot.scale.log_ticks).

Returns

the log Scale.

Complexity

O(1).

Allocation

the Scale.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
let s = figure.log_scale()
f = figure.yscale(f, s)   # -> the classic semilog-y view
fn Axis default_axis() #

A fresh default axis: no label, linear, auto limits, 6 ticks — the one place axis defaults live.

Returns

the default Axis.

Complexity

O(1).

Allocation

the Axis.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let ax = figure.default_axis()
let target = ax.ticks   # -> 6: unlabeled, linear, auto limits
fn Figure grid(builtins::Value auto &&rows, builtins::Value auto &&cols) #

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.

Parameters
rows

the grid rows (clamped up to at least 1).

cols

the grid columns (clamped up to at least 1).

Returns

the empty grid Figure.

Complexity

O(rows·cols).

Allocation

the Figure and its subplots.

System testsystests/test_figure.purr
Example
import 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 cell
fn Figure new_figure() #

A fresh single-subplot figure — the usual starting point.

Returns

the empty 1×1 Figure.

Complexity

O(1).

Allocation

the Figure.

System testsystests/test_figure.purr
Example
import 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 series
fn Figure subplot(builtins::Value auto &&f, builtins::Value auto &&r, builtins::Value auto &&c) #

Point fluent calls at grid cell (r, c) — out-of-range coordinates clamp to the grid.

Parameters
f

the figure.

r

the target row (0-based).

c

the target column (0-based).

Returns

a copy of f targeting that cell.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 cell
fn Figure add(builtins::Value auto &&f, builtins::Value auto &&s) #

Append a pre-built series to the targeted subplot — the bridge between the constructor style (series.line(x, y)) and the fluent style.

Parameters
f

the figure.

s

the series to append.

Returns

a copy of f with s appended to the current subplot.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 subplot
fn Figure 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.

Parameters
f

the figure.

x

the x positions.

y

the y values (same length).

Returns

a copy of f with the line appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 subplot
fn Figure 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.

Parameters
f

the figure.

x

the x positions.

y

the y values (same length).

Returns

a copy of f with the scatter appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 subplot
fn Figure 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.

Parameters
f

the figure.

x

the bar positions.

y

the bar heights (same length).

Returns

a copy of f with the bars appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 bars
fn Figure 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.

Parameters
f

the figure.

x

the x positions.

y

the top edge values (same length).

Returns

a copy of f with the area appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 curve
fn Figure 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.

Parameters
f

the figure.

x

the x positions.

y

the y values (same length).

Returns

a copy of f with the step line appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 line
fn Figure 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.

Parameters
f

the figure.

x

the x positions.

y

the central values.

ylo

the lower whisker ends (absolute).

yhi

the upper whisker ends (absolute).

Returns

a copy of f with the error bars appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 subplot
fn Figure heatmap(builtins::Value auto &&f, ::cheatah::ndarray::basic_ndarray< double > &z) #

Fluent heatmap: append series.heatmap(z) to the targeted subplot.

Parameters
f

the figure.

z

the row-major 2-D value grid.

Returns

a copy of f with the heatmap appended.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 value
fn Figure 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).

Parameters
f

the figure.

data

the samples.

bins

the bin count (clamped up to at least 1).

Returns

a copy of f with the histogram bars appended.

Complexity

O(n + bins + figure).

Allocation

the returned copy plus the histogram arrays.

System testsystests/test_figure.purr
Example
import 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 bins
fn Figure title(builtins::Value auto &&f, builtins::Value auto &&t) #

Set the targeted subplot's title.

Parameters
f

the figure.

t

the title text.

Returns

a copy of f with the title set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
f = figure.title(f, "convergence")   # -> the current subplot is titled
fn Figure xlabel(builtins::Value auto &&f, builtins::Value auto &&s) #

Set the targeted subplot's x-axis label.

Parameters
f

the figure.

s

the label text.

Returns

a copy of f with the label set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
f = figure.xlabel(f, "epoch")   # -> the x axis reads "epoch"
fn Figure ylabel(builtins::Value auto &&f, builtins::Value auto &&s) #

Set the targeted subplot's y-axis label.

Parameters
f

the figure.

s

the label text.

Returns

a copy of f with the label set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
f = figure.ylabel(f, "loss")   # -> the y axis reads "loss"
fn Figure xlim(builtins::Value auto &&f, builtins::Value auto &&lo, builtins::Value auto &&hi) #

Fix the targeted subplot's x limits (overriding auto).

Parameters
f

the figure.

lo

the low limit.

hi

the high limit.

Returns

a copy of f with the limits set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
f = figure.xlim(f, 0.0, 10.0)   # -> x spans exactly [0, 10]; auto is overridden
fn Figure ylim(builtins::Value auto &&f, builtins::Value auto &&lo, builtins::Value auto &&hi) #

Fix the targeted subplot's y limits (overriding auto).

Parameters
f

the figure.

lo

the low limit.

hi

the high limit.

Returns

a copy of f with the limits set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
f = figure.ylim(f, -1.0, 1.0)   # -> y pinned to [-1, 1]
fn Figure xscale(builtins::Value auto &&f, builtins::Value auto &&s) #

Set the targeted subplot's x-axis transform.

Parameters
f

the figure.

s

the Scale (linear() or log_scale()).

Returns

a copy of f with the transform set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
let s = figure.log_scale()
f = figure.xscale(f, s)   # -> decade ticks along x
fn Figure yscale(builtins::Value auto &&f, builtins::Value auto &&s) #

Set the targeted subplot's y-axis transform.

Parameters
f

the figure.

s

the Scale (linear() or log_scale()).

Returns

a copy of f with the transform set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
let s = figure.log_scale()
f = figure.yscale(f, s)   # -> log10 y; ticks land on decades
fn Figure legend(builtins::Value auto &&f, builtins::Value auto &&on) #

Turn the targeted subplot's legend on or off (labeled series get entries when on).

Parameters
f

the figure.

on

true to draw the legend box.

Returns

a copy of f with the flag set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import 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 entries
fn Figure size(builtins::Value auto &&f, builtins::Value auto &&w, builtins::Value auto &&h) #

Set the figure's pixel size.

Parameters
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).

Returns

a copy of f with the size set.

Complexity

O(figure).

Allocation

the returned copy.

System testsystests/test_figure.purr
Example
import plot.figure as figure
let f = figure.new_figure()
f = figure.size(f, 1280, 720)   # -> a 1280x720 canvas
fn const char * module_abi() noexcept #

ABI/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.

Returns

the module name ("figure").