packages

plot::data

On this page

Input data. Data is what every plotting call takes for a series of numbers: a List or an Array of any rank (read in row-major order), of f64, f32, i64, i32 or usize, a fixed array, or an integer range: the forms linalg::AsVector<f64> takes in the other packages. Grid is the 2-d form for heatmaps and contours. Both copy once into a List<f64>, so changing the input afterwards does not change the plot.

Traits

DataSource

pub trait Data

A series of numbers to plot.

nabi
use plot::Data;
use core::array::Matrix;

let m: Matrix<f64> = [[1, 2], [3, 4]];
assert(m.values() == [1.0, 2.0, 3.0, 4.0]);
assert([1, 2].values() == [1.0, 2.0]);
assert((0..3).values() == [0.0, 1.0, 2.0]);
  • fn values(self) -> List<f64>§

    Source

    The values as a new list of f64.

GridSource

pub trait Grid

A 2-d grid of values for heatmap and contour: row i is the i-th y position, from the bottom of the plot unless the layer says otherwise.

nabi
use plot::Grid;

let (z, rows, cols) = [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]].grid();
assert(rows == 2 && cols == 3 && z[5] == 6.0);
  • fn grid(self) -> (List<f64>, usize, usize)§

    Source

    The values in row-major order with the row and column counts. Ragged rows give cols == usize::MAX, which rendering reports.