Skip to main content

Crate ploot

Crate ploot 

Source
Expand description

Terminal plotting with Unicode Braille characters.

ploot renders charts in the terminal using Unicode Braille characters (U+2800–U+28FF), giving 2×4 sub-pixel resolution per terminal cell. Pure Rust, no external processes.

Build plots with typed builder structs (LinePlot, ScatterPlot, BarPlot, …) composed into a Layout2D or Layout3D, then rendered via Figure.

A gnuplot-compatible mutable-borrow API (Figure::axes2d, Axes2D::lines, …) is also available.

§Features

  • Line, scatter, bar, histogram, candlestick, and pie chart plot types
  • Fill-between, error bars, and box-and-whisker plots
  • Heatmaps, contour plots, and heatmap+contour overlays
  • 3D surfaces: wireframe, hidden-line, and color-mapped filled
  • Grid and minor grid with configurable dash patterns
  • Legend with placement control
  • Logarithmic axis scaling
  • Secondary (x2/y2) axes
  • Multiplot (subplot grid) layout
  • LTTB auto-downsampling for large datasets
  • Annotations and arrows
  • Custom tick positions and labels
  • SVG export

§Quick start

use ploot::prelude::*;

let xs: Vec<f64> = (0..=60).map(|i| i as f64 / 10.0).collect();
let ys: Vec<f64> = xs.iter().map(|x| x.sin()).collect();

let layout = Layout2D::new()
    .with_title("Sine wave")
    .with_x_label("x")
    .with_y_label("y")
    .with_plot(LinePlot::new(xs, ys).with_caption("sin(x)"));

let output = Figure::new()
    .with_size(60, 15)
    .with_layout(layout)
    .render();
assert!(!output.is_empty());

For one-off plots without the full builder API, use quick_plot:

let xs: Vec<f64> = (0..=20).map(|i| i as f64).collect();
let ys: Vec<f64> = xs.iter().map(|x| x * x).collect();
let output = ploot::quick_plot(&xs, &ys, Some("x²"), Some("x"), Some("y"), 60, 15);
assert!(output.contains("x²"));

Re-exports§

pub use api::AlignType;
pub use api::AutoOption;
pub use api::Axes2D;
pub use api::Axes3D;
pub use api::AxisPair;
pub use api::Coordinate;
pub use api::DashType;
pub use api::Figure;
pub use api::GridData;
pub use api::LabelOption;
pub use api::LegendOption;
pub use api::Placement;
pub use api::PlotOption;
pub use api::PointSymbol;
pub use api::SeriesData;
pub use api::SurfaceStyle;
pub use api::TickOption;
pub use api::quick_contour;
pub use api::quick_heatmap;
pub use api::quick_plot;
pub use api::quick_plot_multi;
pub use api::quick_surface;
pub use canvas::colormap::ColorMapType;

Modules§

api
Public API types.
canvas
Braille canvas and color primitives.
export
SVG and image export utilities.
layout
Layout engine — tick generation, text grid, and frame rendering.
prelude
Convenient glob import of the most commonly needed types.
render
Rendering pipeline — dispatches Figure data to canvas.
terminal
Terminal size detection.
transform
Coordinate transforms — mapping, clipping, and downsampling.