Skip to main content

Crate plotine

Crate plotine 

Source
Expand description

plotine — a high-level, LLM-friendly Rust native scientific plotting library (static 2D + basic 3D).

use plotine::prelude::*;

let x: Vec<f64> = (0..20).map(|i| i as f64 * 0.1).collect();
let y: Vec<f64> = x.iter().map(|v| v.sin()).collect();
let png = Figure::new()
    .size(4.0, 3.0)
    .dpi(72.0)
    .subplots(2, 1, |g| {
        g.at(0, 0, |ax| {
            ax.line(&x, &y).color(Color::CRIMSON).width(2.0);
            ax.title("Top");
        });
        g.at(1, 0, |ax| {
            ax.scatter(&x, &y).size(3.0);
            ax.title("Bottom");
        });
    })
    .render_png()
    .expect("png");
assert!(!png.is_empty());

See the prelude module and the repository’s AGENTS.md / llms.txt for agent-oriented API guidance.

Re-exports§

pub use animation::AnimFrame;
pub use animation::Animation;
pub use artist::AnnotatePlot;
pub use artist::AreaPlot;
pub use artist::ArrowStyle;
pub use artist::AxHLinePlot;
pub use artist::AxHSpanPlot;
pub use artist::AxLinePlot;
pub use artist::AxVLinePlot;
pub use artist::AxVSpanPlot;
pub use artist::BarHPlot;
pub use artist::BarPlot;
pub use artist::BarbsPlot;
pub use artist::BoxPlot;
pub use artist::BrokenBarHPlot;
pub use artist::ContourPlot;
pub use artist::ContourfPlot;
pub use artist::ErrBars;
pub use artist::ErrorBarPlot;
pub use artist::EventPlot;
pub use artist::FillBetweenPlot;
pub use artist::FillBetweenXPlot;
pub use artist::HLinesPlot;
pub use artist::HeatmapPlot;
pub use artist::HexbinPlot;
pub use artist::Hist2dPlot;
pub use artist::HistPlot;
pub use artist::LinePlot;
pub use artist::PcolorMeshPlot;
pub use artist::PiePlot;
pub use artist::PolarFramePlot;
pub use artist::PolygonPlot;
pub use artist::QuiverPlot;
pub use artist::ScatterPlot;
pub use artist::SpyPlot;
pub use artist::StackPlot;
pub use artist::StairsPlot;
pub use artist::StemPlot;
pub use artist::StepPlot;
pub use artist::StreamPlot;
pub use artist::TablePlot;
pub use artist::TextPlot;
pub use artist::TricontourPlot;
pub use artist::TricontourfPlot;
pub use artist::TripcolorPlot;
pub use artist::VLinesPlot;
pub use artist::ViolinPlot;
pub use axes::category_indices;
pub use axes::Axes;
pub use axes::GridAxis;
pub use axes3d::Axes3D;
pub use figure::Figure;
pub use geo::GeoProjection;
pub use layout::GridSpec;
pub use legend::Legend;
pub use nav::NavMode;
pub use nav::ViewHistory;
pub use projection::Camera;
pub use recipes::HeatmapOrigin;
pub use recipes::StepMode;
pub use recipes::TableLoc;
pub use secondary::SecondaryAxis;
pub use secondary::SecondaryTransform;
pub use series::IntoSeries;
pub use series::Series;
pub use style::Hatch;
pub use style::LineStyle;
pub use style::MarkerStyle;
pub use style::Spines;
pub use subplots::SubplotGrid;
pub use theme::Theme;
pub use tick_format::TickFormatter;
pub use view::Axes3DView;
pub use view::PanelView;
pub use view::ViewSnapshot;

Modules§

animation
Offline multi-frame animation (PNG sequence / GIF / MP4). Offline multi-frame animation (matplotlib FuncAnimation semantics).
artist
Mutable plot artists returned by Axes methods. Mutable plot artists returned by Axes plotting methods.
axes
Axes panel API (limits, scales, chart methods).
axes3d
3D axes panel (line3d, scatter3d, surface, wireframe, bar3d). 3D axes panel: camera, data ranges, and 3D artist methods.
figure
Top-level figure builder and rendering entry points.
geo
Geographic projections + coastline (cartopy-thin). Geographic projections (cartopy-thin subset) and coastline layer.
latex
External LaTeX via system latex/dvipng (feature = "latex" + Figure::usetex). External LaTeX rendering (feature = "latex").
layout
Subplot grid geometry and tight-layout insets. Figure / subplot layout: grid cells + tight-layout margin solving.
legend
Legend placement. Legend placement for labeled artists.
math
Unicode helpers for Greek letters and super/subscripts in labels. Lightweight Unicode helpers for axis labels and titles.
mathtext
Matplotlib-style mathtext layout ($...$, fractions, scripts; no LaTeX binary). Matplotlib-style mathtext layout (TeX-like $...$, no external LaTeX).
mpl_policy
Matplotlib-aligned geometry / style policy (shared by layout, polar, pie, …). Matplotlib-aligned geometry and style policy.
nav
Matplotlib-aligned navigation math and view history. Matplotlib-aligned navigation math (pan / zoom / 3D rotate) and view history.
polars
Polars DataFrame → Series adapters (feature = "polars").
prelude
Convenient re-exports for application crates and agents. Common imports for plotine users and coding agents.
projection
3D→2D projection utilities (camera, rotation, painter’s algorithm). 3D→2D projection for Axes3D (matplotlib mplot3d look-at + perspective).
recipes
Pure geometry recipes (advanced / testing). Pure geometry recipes: data → draw primitives (no rendering).
secondary
Secondary axis transforms (matplotlib secondary_xaxis / secondary_yaxis). Secondary axes: transformed tick labels on the opposite spine.
series
Numeric series adapters (IntoSeries). Data input adapters (IntoSeries).
stats
Seaborn-style statistical helpers (corr_heatmap / pair_scatter / regline). Seaborn-style statistical helpers (thin layer over core artists).
style
Line dash patterns, marker shapes, and spine visibility. Line dash patterns, marker shapes, hatch fills, and spine visibility.
subplots
Multi-panel subplot grid builder. Subplot grid builder used by Figure::subplots.
theme
Built-in visual themes. Visual themes and point→pixel conversion helpers.
tick_format
Custom tick label formatting (matplotlib FuncFormatter / StrMethodFormatter).
view
Interactive view snapshots (limits / 3D camera). Interactive view state: capture / apply axis limits and 3D camera.

Structs§

Color
8-bit sRGB color with optional alpha.
ColorParseError
Error returned by Color::from_str.
SegmentedColormap
User-defined colormap from color stops (matplotlib LinearSegmentedColormap subset).

Enums§

Cmap
Named or custom colormap handle used by heatmap / hist2d / … artists.
Colormap
Named continuous colormap.
Norm
How scalar data is normalized into [0, 1] before sampling a colormap.
PlotError
Library-wide error type. Every variant carries a human/agent-readable suggestion.
ScaleType
Which continuous scale an axis uses.
TextAlign
TextBaseline

Type Aliases§

Result
Convenient alias used throughout plotine.