packages

plot::frame

Plotting the columns of a table::Table by name, with the table feature. Each function takes the table first, so it pipes: t |> plot::frame::scatter("x" ↦ "y"). Numeric columns plot as they are (nulls as gaps), date and datetime columns as dates with a date axis, and by splits the rows by a text column into one labelled layer per value.

Functions

lineSource

pub fn line(t: Table, f: Formula, by: str = "") throws (PlotError) -> Axes

A line of column f.y against f.x, one per value of column by when given.

nabi
use plot::ops::MapsTo;

let t = table::table! { "day": [1, 2, 3], "temp": [3.5, 4.0, 2.5] };
let ax = try t |> plot::frame::line("day" ↦ "temp");
assert((try ax.svg()).contains(">temp<"));

scatterSource

pub fn scatter(t: Table, f: Formula, by: str = "") throws (PlotError) -> Axes

Markers at columns f.x, f.y, one colour per value of by.

nabi
use plot::ops::MapsTo;

let t = table::table! { "x": [1.0, 2.0, 3.0, 4.0], "y": [2.0, 1.0, 4.0, 3.0], "g": ["a", "b", "a", "b"] };
let ax = try plot::frame::scatter(t, "x" ↦ "y", by: "g");
assert(ax.len() == 2);

linesSource

pub fn lines(t: Table, x: str, ys: List<str>) throws (PlotError) -> Axes

Several columns as lines against column x, labelled by name.

nabi
let t = table::table! { "x": [1, 2, 3], "a": [1.0, 2.0, 3.0], "b": [3.0, 2.0, 1.0] };
assert((try plot::frame::lines(t, "x", ["a", "b"])).len() == 2);

histSource

pub fn hist(t: Table, column: str, bins: Bins = Bins::Auto) throws (PlotError) -> Axes

A histogram of a column.

nabi
let t = table::table! { "v": [1.0, 2.0, 2.0, 3.0] };
assert((try (try plot::frame::hist(t, "v")).svg()).contains(">v<"));

barSource

pub fn bar(t: Table, f: Formula) throws (PlotError) -> Axes

Bars of column f.y at the labels in column f.x.

nabi
use plot::ops::MapsTo;

let t = table::table! { "city": ["a", "b"], "pop": [3, 5] };
assert((try (try plot::frame::bar(t, "city" ↦ "pop")).svg()).contains(">b<"));

boxplotSource

pub fn boxplot(t: Table, y: str, by: str) throws (PlotError) -> Axes

Box plots of column y per value of column by.

nabi
let t = table::table! { "y": [1.0, 2.0, 3.0, 4.0], "g": ["a", "a", "b", "b"] };
assert((try (try plot::frame::boxplot(t, "y", "g")).svg()).contains(">b<"));