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§
Structs§
- Annotation
- A labeled annotation attached to a row of the plot body.
- Barplot
Graphics - Graphics area for horizontal bar charts with optional fractional block rendering.
- Barplot
Options - Configuration for barplot construction.
- Boxplot
Graphics - Graphics area for box-and-whisker plots. Each series occupies three character rows rendering the five-number summary (min, Q1, median, Q3, max).
- Boxplot
Options - Configuration for boxplot construction.
- Edge
Decorations - Optional text placed at the six edge positions around the plot border (top-left, top-center, top-right, bottom-left, bottom-center, bottom-right).
- Histogram
Options - Configuration for histogram construction.
- Lineplot
Options - Configuration for lineplot, scatterplot, stairs, and density construction.
- Lineplot
Series Options - 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.
- Plot
Annotations - All annotations attached to a plot: left-side labels, right-side labels, and edge decorations.
Enums§
- Barplot
Error - Errors returned by barplot construction and mutation.
- Boxplot
Error - Errors returned by boxplot construction and mutation.
- Closed
Interval - Which end of each histogram bin interval is closed.
- Decoration
Position - One of the six edge decoration positions around the plot border.
- Grid
Canvas - A runtime-selected canvas backend for line, scatter, and density plots.
- Histogram
Error - Errors returned by histogram construction.
- Lineplot
Error - Errors returned by lineplot, scatterplot, stairs, and density construction.
- Stair
Style - 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.