Skip to main content

Crate unicode_plot

Crate unicode_plot 

Source
Expand description

A Unicode terminal plotting library for Rust.

This crate provides canvas-based rendering of plots using Unicode characters (braille, block elements, ASCII, dot, and density characters) for display in terminal emulators. It is a Rust port of the rendering layer from unicode_plot.rb and UnicodePlots.jl.

§Quick start

use unicode_plot::{barplot, BarplotOptions};

let plot = barplot(
    &["cat", "dog", "parrot"],
    &[30, 45, 12],
    BarplotOptions::default(),
).unwrap();

let mut output = Vec::new();
plot.render(&mut output, false).unwrap();
let text = String::from_utf8(output).unwrap();
assert!(text.contains("dog"));

Modules§

border
canvas
color
graphics

Structs§

Annotation
A labeled annotation attached to a row of the plot body.
BarplotGraphics
Graphics area for horizontal bar charts with optional fractional block rendering.
BarplotOptions
Configuration for barplot construction.
BoxplotGraphics
Graphics area for box-and-whisker plots. Each series occupies three character rows rendering the five-number summary (min, Q1, median, Q3, max).
BoxplotOptions
Configuration for boxplot construction.
EdgeDecorations
Optional text placed at the six edge positions around the plot border (top-left, top-center, top-right, bottom-left, bottom-center, bottom-right).
HistogramOptions
Configuration for histogram construction.
LineplotOptions
Configuration for lineplot, scatterplot, stairs, and density construction.
LineplotSeriesOptions
Options for an additional series appended to an existing lineplot or scatter plot.
Plot
A complete plot: graphics area, annotations, border, title, and axis labels.
PlotAnnotations
All annotations attached to a plot: left-side labels, right-side labels, and edge decorations.

Enums§

BarplotError
Errors returned by barplot construction and mutation.
BoxplotError
Errors returned by boxplot construction and mutation.
ClosedInterval
Which end of each histogram bin interval is closed.
DecorationPosition
One of the six edge decoration positions around the plot border.
GridCanvas
A runtime-selected canvas backend for line, scatter, and density plots.
HistogramError
Errors returned by histogram construction.
LineplotError
Errors returned by lineplot, scatterplot, stairs, and density construction.
StairStyle
Step direction for staircase plots.

Functions§

annotate
Places edge annotation text on a line plot.
barplot
Constructs a bar plot from labels and values.
barplot_add
Appends rows to an existing bar plot.
boxplot
Constructs a boxplot from one or more numeric series.
boxplot_add
Appends a series to an existing boxplot.
densityplot
Constructs a densityplot from explicit x/y values.
densityplot_add
Adds a density series to an existing density plot.
histogram
Constructs a histogram by binning data and delegating rendering to barplot.
lineplot
Constructs a lineplot from explicit x/y values.
lineplot_add
Adds a line series to an existing plot.
lineplot_add_slope
Adds a slope/intercept line to an existing plot.
lineplot_add_y
Adds a y-only line series to an existing plot with implicit x = 1..=n.
lineplot_y
Constructs a lineplot from y values with implicit x = 1..=n.
parse_border_type
Parses a border name into a BorderType.
scatterplot
Constructs a scatterplot from explicit x/y values.
scatterplot_add
Adds a scatter series to an existing plot.
scatterplot_add_y
Adds a y-only scatter series to an existing plot with implicit x = 1..=n.
scatterplot_y
Constructs a scatterplot from y values with implicit x = 1..=n.
stairs
Constructs a staircase plot from explicit x/y values.
stairs_add
Adds a staircase series to an existing plot.