ploot
Note: This is almost entirely machine generated code. It works for my applications but comes with absolutely no guarantees regarding API stability or anything else. Use at your own risk.
A terminal plotting library for Rust that renders charts using Unicode Braille characters (U+2800-U+28FF).
Each terminal cell encodes a 2x4 sub-pixel grid, giving smooth curves at high effective resolution without leaving the terminal. Zero dependencies, pure Rust.
Gallery
Line plots with legend, grid, and dash styles
Multiple series with automatic color cycling
Bar chart
Heatmap
Color-mapped density rendering of 2D scalar fields using Braille dot density + ANSI color.
Contour plot
Isolines extracted via marching squares, drawn as Braille curves.
Heatmap + contour overlay
Dual Y-axis
Independent primary and secondary y-axes with automatic range detection.
3D wireframe surface
3D hidden-line surface
Depth-buffered wireframe with per-pixel occlusion.
3D filled surface
Color-mapped density shading with wireframe overlay.
Scatter plot
Six marker styles: dot, cross, circle, diamond, triangle, square.
Histogram
Automatic binning of raw data into bar counts.
Box-and-whisker
Statistical summary plots showing median, quartiles, and range.
Confidence band (fill-between)
Shaded area between two curves for uncertainty visualization.
Candlestick chart
OHLC financial data rendered as candlestick bodies with high/low wicks.
Pie chart
Proportional arc segments with labels rendered via Braille density fill.
Usage
Add ploot to your Cargo.toml:
[]
= "0.1.5"
Line plot
use *;
let xs: = .map.collect;
let quadratic: = xs.iter.map.collect;
let sine: = xs.iter.map.collect;
let layout = new
.with_title
.with_x_label
.with_y_label
.with_y_grid
.with_plot
.with_plot;
new
.with_size
.with_layout
.show;
Scatter plot
use *;
let xs: = .map.collect;
let ys: = .map.collect;
let layout = new
.with_title
.with_plot;
new
.with_size
.with_layout
.show;
Heatmap
use *;
let grid = from_fn;
let layout = new
.with_title
.with_x_label
.with_y_label
.with_plot;
new
.with_size
.with_layout
.show;
Contour
use *;
let grid = from_fn;
let layout = new
.with_title
.with_plot;
new
.with_size
.with_layout
.show;
Heatmap + contour overlay
use *;
let grid = from_fn;
let layout = new
.with_title
.with_plot;
new
.with_size
.with_layout
.show;
3D surface
use *;
let grid = from_fn;
let layout = new
.with_title
.with_view
.with_colormap
.with_surface;
new
.with_size
.with_layout3d
.show;
Other surface styles: SurfaceStyle::Wireframe, SurfaceStyle::HiddenLine.
Dual Y-axis
use *;
let months: = .map.collect;
let temperature = vec!;
let rainfall = vec!;
let layout = new
.with_title
.with_x_label
.with_y_label
.with_plot
.with_plot;
new
.with_size
.with_layout
.show;
Quick one-shot API
For throwaway plots without the builder:
let xs: = .map.collect;
let ys: = xs.iter.map.collect;
let output = quick_plot;
println!;
Features
2D plots
- Line plots - solid, dashed, dotted, and custom dash patterns
- Scatter plots - six marker styles: dot, cross, circle, diamond, triangle, square
- Bar charts - filled boxes with configurable width
- Histograms - automatic binning of raw data with optional normalization
- Fill-between - shaded area between two curves
- Error bars - X and Y error bars, with or without connecting lines
- Box-and-whisker - statistical summary plots
- Candlestick - OHLC financial data with body and wick rendering
- Pie chart - proportional arc segments with labels
2D grid data
- Heatmap - color-mapped density rendering of Z(x,y) scalar fields using Braille dot density + ANSI color (7 colors x 8 density levels = 56 perceptual levels)
- Contour - isolines via marching squares with linear interpolation and saddle-point disambiguation
- Heatmap + contour overlay - combined density shading with isoline overlay
3D surfaces
- Wireframe - projected mesh lines from configurable azimuth/elevation viewpoint
- Hidden-line - depth-buffered wireframe with per-pixel z-test occlusion
- Filled - color-mapped density shading per quad with wireframe overlay
- Colormaps - Heat, Gray, Rainbow, BlueRed
Rendering
- Braille rendering - 2x4 sub-pixel resolution per terminal cell via bitwise dot compositing
- ANSI color - automatic 7-color palette cycling (blue, red, green, yellow, cyan, magenta, white), with additive color mixing when curves overlap
- Line drawing - Bresenham's algorithm with dash pattern support
- Viewport clipping - Cohen-Sutherland algorithm clips lines to canvas bounds
- Depth buffer - z-buffer for correct 3D occlusion (front-to-back rendering)
Layout and axes
- Axis layout - auto-generated tick marks using Heckbert's nice numbers algorithm
- Secondary axes - independent x2/y2 axes with separate ranges, labels, and tick marks
- Logarithmic scaling - per-axis log-scale support with any base
- Grid lines - major and minor grid with configurable color and dash patterns
- Legend - automatic legend with 4-corner placement control
- Annotations - text labels and arrows in data or graph coordinates
- Custom ticks - user-defined tick positions and labels
- Axis reversal - flip axis direction
- Multiplot - subplot grid layout with shared super-title (2D and 3D can be mixed)
Data handling
- LTTB downsampling - automatic downsampling for large datasets
- GridData - 2D matrix with
from_fn(sample a function) andfrom_rows(nested iterators) constructors, bilinear interpolation - Terminal size detection - auto-detect terminal dimensions via ioctl/env fallback
- Zero dependencies - pure Rust, no external crates
Architecture
API (Figure, Axes2D, Axes3D, GridData, options, series data)
|
+-- Render
| +-- 2D: lines, points, boxes, fill, error_bars, box_whisker, heatmap, contour
| +-- 3D: surface (wireframe, hidden-line, filled)
| +-- Overlays: grid, legend, annotations
|
+-- Layout (space allocation, tick generation, frame rendering)
|
+-- Transform
| +-- CoordinateMapper (data -> pixel), clipping, downsampling
| +-- Projection (3D -> 2D rotation), marching squares
|
+-- Canvas
+-- BrailleCanvas (Bresenham lines, dash patterns, color compositing)
+-- DepthCanvas (z-buffer wrapper for 3D occlusion)
+-- ColorMap (value -> color + density mapping)
Examples
Run any example from the examples/ directory:
License
Apache-2.0