dataviz
Fast plotting for Rust and Python. 120+ chart types — statistics, machine learning, finance and order flow, genomics, maps, business charts, 3D surfaces, molecules and isosurfaces — drawn by one anti-aliased renderer that needs no system libraries, no Python and no browser.
- Fast and light: 5–22× faster than matplotlib from Python, the least CPU and memory of the Rust plotting crates (see Performance).
- Interactive: windows with zoom, pan, crosshair, linked plots and live data; HTML pages with hover and 3D rotation; the same interaction inside egui or WebAssembly apps.
- Everywhere: PNG, SVG, PDF, JPEG, WebP, interactive HTML, animated GIF/APNG/MP4, the terminal, raw pixels; Python; a Claude Code plugin.
#![allow(unused)]
fn main() {
use dataviz::prelude::*;
let x: Vec<f64> = (0..200).map(|i| i as f64 / 20.0).collect();
let mut fig = Figure::new(800, 450);
fig.axes()
.title("Signals")
.line(&x, x.iter().map(|v| v.sin()))
.label("sin");
fig.save("signals.png")?;
Ok::<(), dataviz::plot::Error>(())
}
This guide shows how to install it, give it your data, choose a chart, make it interactive and get it out — and the chart catalog shows every chart type with its code. Try it in the browser: live demo (WebAssembly).
Installation
Rust
[dependencies]
dataviz = "1"
Optional features:
| Feature | Adds | Default |
|---|---|---|
window | interactive windows (fig.show, fig.show_live) | on |
pdf | PDF output | off |
gpu | GPU rasterizer (wgpu: Vulkan, Metal, DX12, OpenGL) | off |
regions | states and provinces of every country (+0.8 MB) | off |
spec | figures from JSON specs (plot::spec) | off |
Headless servers and WebAssembly: default-features = false.
dataviz = { version = "1", default-features = false, features = ["pdf"] }
No system libraries are needed (the font is built in; on Linux the window uses X11 or Wayland when present).
Python
pip install dataviz-rs
See Python.
Claude Code
/plugin marketplace add dataviz-rs/dataviz
/plugin install dataviz@dataviz
See Claude and MCP.
Quick start
A figure holds one or more plots (Axes); every chart is a method of an
axes, and options chain.
#![allow(unused)]
fn main() {
use dataviz::prelude::*;
let x: Vec<f64> = (0..100).map(|i| i as f64 / 10.0).collect();
let mut fig = Figure::new(900, 500);
fig.title("Two plots");
fig.grid(1, 2);
let ax = fig.at(0, 0);
ax.title("Lines").x_label("t [s]").y_label("value");
ax.line(&x, x.iter().map(|v| v.sin())).label("sin");
ax.line(&x, x.iter().map(|v| v.cos())).label("cos").dash(Dash::Dashed);
let ax = fig.at(0, 1);
ax.title("Bars");
ax.bar(["Q1", "Q2", "Q3", "Q4"], [3.0, 5.0, 4.0, 6.0]).label("2025");
fig.save("quick.png")?; // .svg .pdf .jpg .webp .html too
fig.show("quick start")?; // a window: zoom, pan, crosshair
Ok::<(), dataviz::plot::Error>(())
}
fig.grid(rows, cols)andfig.at(row, col)(orfig.span(row, col, rowspan, colspan)) lay out several plots;fig.share_x(true)links them.- Themes:
fig.theme(Theme::dark())(alsominimal,ggplot,seaborn,publication,solarized,high_contrast). - Text takes TeX math between dollars:
ax.y_label(r"$\sigma^2$ [m²]").
Live data
let mut fig = Figure::new(900, 400);
fig.axes().line(Vec::<f64>::new(), Vec::<f64>::new()).label("signal");
let mut t = 0.0;
fig.show_live("live", 30, |fig| {
t += 0.05;
let line = fig.axes().series_mut::<dataviz::plot::series::line::Line>(0).unwrap();
line.push(t, t.sin());
line.keep_last(500);
true // redraw
})?;
Your data
Every chart takes values through IntoValues: anything iterable over
numbers — Vec, slices, arrays, ranges, iterators — of any numeric type,
Options (None becomes a gap) and booleans (1/0).
ax.line(&x, &y); // Vec<f64>, &[f32], i64, …
ax.line(0..100, data.iter().map(|d| d.price)); // ranges and iterators
ax.line(&array1, &array1.mapv(f64::sin)); // ndarray
ax.line(×, df.column("price")?.f64()?); // Polars (nulls → gaps)
ax.scatter(arrow_x.values(), &arrow_y); // Arrow arrays
Data passed to a series is moved, not copied.
CSV files
use dataviz::plot::data::Table;
let t = Table::read("prices.csv")?; // , ; tab or | detected
ax.line(t.time_column("date").unwrap(), t.column("close").unwrap());
ax.x_scale(Scale::Time);
Dates and times
Time values are seconds since 1970 (UTC): date(2025, 3, 1),
datetime(2025, 3, 1, 9, 30, 0) or parse_datetime("2025-03-01T09:30");
ax.x_scale(Scale::Time) picks readable ticks from seconds to decades.
Live data
Line::push, keep_last and keep_since stream into a chart;
plot::data::CsvLog records the stream to a CSV file.
Choosing a chart
| You want to show | Chart | Method |
|---|---|---|
| a trend over time | line, area, step | line, area, line(…).step(…) |
| many series over time | small multiples, horizon | facet_wrap, horizon |
| values per category | bars (horizontal for long names) | bar, barh |
| change between two times | slope, dumbbell | slope, dumbbell |
| rankings over time | bump chart | bump |
| a distribution | histogram, KDE, ECDF | hist, kde, ecdf |
| distributions of groups | box, violin, raincloud, swarm, ridgeline | boxplot, violin, raincloud, swarm, ridgeline |
| relationship of two variables | scatter, regression, density | scatter, regplot, density_contour, hexbin |
| many variables at once | pair plot, correlation matrix, parallel coordinates | pair_plot, heatmap, parallel_coordinates |
| parts of a whole | pie (few parts), waffle, treemap, sunburst, marimekko | pie, waffle, treemap, sunburst, marimekko |
| flows | sankey, chord, flow map | sankey, chord, geo_flows |
| performance against targets | bullet, gauge, Pareto | bullet, gauge, pareto |
| a process in control | SPC control chart | control_chart |
| model quality | ROC, PR, calibration, confusion matrix, SHAP | roc_curve, pr_curve, calibration_curve, confusion_matrix, shap_summary |
| prices | candlestick, Heikin-Ashi, Renko, footprint, market profile | candlestick, heikin_ashi, renko, footprint, market_profile |
| countries or regions | choropleth, region map, hexbin map | choropleth, region_map, geo_hexbin |
| genomics | Manhattan, volcano, Circos, Hi-C, oncoprint | manhattan, volcano, circos, hic, oncoprint |
| a function of two variables | heatmap, contours, 3D surface | heatmap, contour, surface |
| structures | DNA helix, molecule, isosurface | dna_helix, molecule, isosurface |
Each has its code and picture in the chart catalog.
Chart catalog
Every chart type with a picture and its code, grouped like the gallery.
- Live, interactive and animated
- For data scientists, biologists, engineers and traders
- Lines, points and bars
- Statistics
- Finance and time
- Grids, fields and 3D
- Maps
- Parts, flows and polar
- Axes, layout, text and style
Live, interactive and animated
Interactive window and live data
Figure::show opens a window: mouse wheel zooms around the cursor, left-drag pans, right-drag zooms to a box, the range slider below the plot is dragged to pan and at its edges to zoom, Shift+drag measures (Δx, Δy, change in %), Ctrl+drag selects a box (Figure::selection()), clicking a legend row hides or shows its series, R resets, C toggles the crosshair (cursor values on the axes and the series values at that x), H toggles hover tooltips, S saves a PNG, Shift+S an SVG, Ctrl+C copies to the clipboard, V records a GIF, Esc closes. Plots showing the same x range get a linked cursor and are zoomed and panned together. Figure::show_live then streams data into a rolling window.
The animation was recorded with cargo run --release -- --demo: wheel zoom and drag through the same calls a window or GUI makes (zoom_at, pan_by, reset_view), the range slider following the view.
Code of this example · cargo run --release -p plot-interactive
Live streaming data
A live dashboard for data that keeps arriving: a producer thread sends
samples over a channel, the window takes everything that arrived since the
last frame and redraws (Figure::show_live, 30 frames per second).
- top: the last 30 seconds of every channel on a time axis (UTC), latest
values in the title (
Line::push+Line::keep_since), - bottom left: distribution of the first channel in that window
(
Histogram::set_values), - bottom right: incoming samples per second.
Data sources
| Source | Data |
|---|---|
sim (default) | Simulated sensors at 100 Hz: temperature, humidity, vibration with bursts |
cpu | This machine’s real CPU and memory use, 10 Hz (Linux, /proc) |
stdin | Any numbers piped in, one sample per line (spaces, commas or tabs); a non-numeric first line names the channels |
Code of this example · cargo run --release -p plot-streaming
Animations
A travelling wave packet and the phase portrait of a damped oscillator,
recorded with Figure::record as a GIF, a lossless animated PNG and a
lossless animated WebP (the format follows the extension).
Only the part of each frame that changed is stored. For 90 frames at 820×520:
| Format | Size | Time | Colors |
|---|---|---|---|
| GIF | 815 KB | 0.23 s | at most 256 per frame |
| APNG | 2169 KB | 0.14 s | full color, transparency |
| WebP | 1858 KB | 0.15 s | full color, transparency |
The same call writes .mp4 / .webm when | |||
ffmpeg is installed. For data arriving over time, use Recorder::push_at | |||
(see plot-streaming); in a window V records a GIF. |
Code of this example · cargo run --release -p plot-animation
Live Binance market dashboard
Live BTC/USDT (or any spot symbol) from Binance’s public market-data API,
redrawn about once a second (Figure::show_live, dark theme):
- 1-minute candlesticks with MA(7) and MA(25) and the last price,
- volume per minute (total and taker buys),
- every trade of the last two minutes (buys green, sells red, marker size by amount),
- order-book depth (cumulative bids and asks, 500 levels),
- taker buy minus sell volume per 10 seconds,
- 24 h change, high, low and volume in the title.
A background thread polls https://data-api.binance.vision/api/v3
(trades, depth, klines, ticker/24hr) with the system’s curl, so
there is no HTTP or JSON dependency and no API key; the window only redraws
when new data arrived. Times are shown in the local time zone.
Code of this example · cargo run --release -p plot-binance
Interactive HTML
fig.save("weather.html") writes one self-contained file: the chart as
SVG with a small script, no server, no internet access and no external
scripts needed. In the browser:
- a crosshair with the cursor’s x and y values on the axes,
- a tooltip with every series’ value at the cursor’s x (and a linked cursor in plots sharing the x range),
- clicking a legend row hides or shows its series,
- a button saves the chart as PNG.
Code of this example · cargo run --release -p plot-html
dataviz in the browser (WebAssembly)
The chart is rendered by Rust compiled to WebAssembly into an RGBA buffer
that a few lines of JavaScript put on a <canvas>. Two sensors stream in
every frame; the wheel zooms, dragging pans, a double-click follows the
data again, hovering shows the nearest value and clicking a legend row
hides or shows a series — all handled by dataviz in Rust.
No wasm-bindgen or other JavaScript tooling: the module exports plain
functions (init, step, render, wheel, drag, reset, click,
hover) and imports nothing. Release build: 3.1 MB (1.2 MB gzipped, the
embedded font and text shaping included); a frame (new data + render at
960×520 with 2 × 3000 points) takes about 1.7 ms in V8.
The interaction calls (Figure::zoom_at, pan_by, zoom_to_box,
reset_view, hover, click) are the same for any GUI toolkit that
shows the figure’s pixels (Figure::render_into).
Code of this example · cargo run --release -p plot-wasm
dataviz inside an egui app
A live chart in an egui application: each
frame the figure is rendered into a texture at the panel’s size
(Figure::render_into, sharp on HiDPI screens) and the mouse is passed on
with dataviz’s window-free interaction API — wheel to zoom (zoom_at),
drag to pan (pan_by), hover readouts (hover), legend clicks (click),
double-click to reset (reset_view). The side panel changes the data
speed, noise and theme while it streams.
The same approach works with any toolkit that can show an RGBA image (iced, Slint, GTK, Qt, …).
Code of this example · cargo run --release -p plot-egui
Raster backends
The same real-time chart (1920×1080, rolling 100 000 points) drawn on one CPU
thread, on all cores and, with --features gpu, on the GPU (Vulkan, Metal,
DirectX 12 or OpenGL through wgpu). Prints the time and CPU time per frame.
Built with the dataviz::plot API
(Figure::backend, Figure::render_0rgb).
Code of this example · cargo run --release -p plot-backends
Terminal output
Charts printed in the terminal with 24-bit colored half blocks or braille dots (Figure::to_terminal, Figure::print), e.g. over SSH or in CI logs.
Braille output (TerminalMode::BrailleMono) is saved to screenshots/terminal.txt.
Code of this example · cargo run --release -p plot-terminal
dataviz from C and C++
The dataviz renderer as a C library with a header-only C++17 wrapper
(dataviz.h, dataviz.hpp). It runs on Linux, macOS and Windows, and
iOS and Android get static libraries. CMake downloads dataviz and builds
the library with cargo, so you need CMake 3.16+, a C/C++ compiler and
Rust.
dashboard.cpp builds the dashboard above and saves it
as PNG and SVG in about 85 ms. It uses three ways in:
- Direct calls:
line,scatter,hist,heatmap,density,scatter3d,surface,candlestick. - Any chart type through a JSON spec: large arrays stay binary. A
field
"@a"takes the array nameda, copied once and never turned into text. For 1 M points this takes 4 ms; the same data as JSON numbers takes 166 ms. - The grammar of graphics: data, a mark and encodings.
#include "dataviz.hpp"
dataviz::Figure fig(1200, 800);
auto ax = fig.axes(0, 0);
ax.line(t, signal, dataviz::Style().label("signal").width(1.0));
ax.title("Signal").xlabel("time (s)");
fig.axes(1, 0).plot(R"({"type": "violin", "groups": {"auth": "@a", "search": "@b"}})",
{{"a", auth_ms}, {"b", search_ms}});
fig.save("dashboard.png"); // .svg .pdf .html .jpg .webp
live.c is a live window in plain C: a sensor value arrives
every frame, the last 600 points are kept, and zoom, pan and hover work.
static int update(dv_figure *fig, void *user) {
state *s = user;
dv_series_push(s->raw, s->t, read_sensor(), 600);
return 1; /* redraw */
}
dv_figure_show_live(fig, "sensor", 60, update, &s);
In your own UI (Qt, GTK, Dear ImGui, SDL, a game engine),
dv_figure_render returns RGBA pixels to upload as a texture.
dv_figure_zoom, dv_figure_pan, dv_figure_click and
dv_figure_hover handle the user’s input.
Code of this example · cargo run --release -p plot-c-cpp
Grammar of graphics
A chart described by data, a mark and encodings, the way Vega-Lite, ggplot2 and Altair describe charts. From the encodings dataviz derives:
- color groups with a legend;
- aggregation (
count,sum,mean,median,min,max); - histograms, when x is binned;
- stacked, grouped or percent bars;
- heatmaps (
rect) and box plots; - small multiples (
facet), with the same colors in every plot and a single legend.
#![allow(unused)]
fn main() {
use dataviz::plot::grammar::{Aggregate, Chart, Data, Field, Mark};
let data = Data::new()
.text("species", species)
.text("island", island)
.num("body mass (g)", mass);
Chart::new(data, Mark::Bar)
.x("island")
.y(Field::new("body mass (g)").aggregate(Aggregate::Mean))
.color("species")
.stack(BarMode::Grouped)
.draw(&mut fig)?;
}
The same chart as a JSON spec works from Python, JavaScript, C/C++ and the MCP server:
{"data": {"island": [...], "species": [...], "body mass (g)": [...]},
"mark": "bar",
"encoding": {"x": "island", "y": {"field": "body mass (g)", "aggregate": "mean"}, "color": "species"},
"stack": "grouped"}
In Python, with pandas or Polars DataFrames and Altair shorthand:
dv.plot(df, "bar", x="island", y="mean(body mass (g))", color="species", stack="grouped")
Speed: 1 000 000 rows in 3 color groups build in about 30 ms; with the PNG saved, about 120 ms.
Code of this example · cargo run --release -p plot-grammar
For data scientists, biologists, engineers and traders
Charts for data scientists
ROC curves with the AUC in the legend, a precision-recall curve, a normalized confusion matrix, a regression line with its 95 % confidence band and R², 2D density contours of 20 000 points and a dendrogram of hierarchical clustering.
#![allow(unused)]
fn main() {
ax.roc_curve("gradient boosting", &labels, &scores);
ax.pr_curve("gradient boosting", &labels, &scores);
ax.confusion_matrix(["cat", "dog", "bird"], &actual, &predicted, true);
ax.regplot(&x, &y);
ax.density_contour(&a, &b);
ax.dendrogram(names, &features);
}
Model evaluation and explanation
A SHAP summary (beeswarm) of a credit-default model, calibration curves of a well calibrated and an over-confident model (Brier scores in the legend), a learning curve with ±1σ bands, a cumulative gain chart, a raincloud plot (half violin, box and points) and an UpSet plot of genes found by four assays.
#![allow(unused)]
fn main() {
ax.shap_summary(&feature_names, &shap_values, &feature_values, 10);
ax.calibration_curve("logistic", &labels, &probabilities, 10);
ax.learning_curve(&sizes, &train_scores, &validation_scores);
ax.gain_curve("logistic", &labels, &scores); // also lift_curve
ax.raincloud([("eu-west", a), ("us-east", b)]);
ax.upset(&[("RNA-seq", genes_a), ("ATAC-seq", genes_b)], 12);
}
Code of this example · cargo run --release -p plot-data-science
Charts for biology, genomics and medicine
A DNA sequence logo (letters scaled to their information content), a gene track (exons, introns, strand), a GWAS Manhattan plot with its p-value Q-Q plot, a volcano plot naming the top genes, single-cell clusters on a UMAP, a dose-response curve with a four-parameter logistic fit and IC50, Kaplan-Meier survival with the log-rank test, a forest plot of hazard ratios, and a clustermap of gene expression.
Genomics: a Circos plot (hg38 chromosomes, copy number, translocations), a Hi-C contact map with TADs, exome coverage with a minimum-depth check, phylogenetic trees from Newick text (rectangular and circular), an oncoprint of ten cancer genes and TP53 mutations along the protein.
#![allow(unused)]
fn main() {
ax.circos(&chromosomes).track(&chrom, &pos, ©_number).links(&translocations);
ax.hic(matrix, 1.0, 0.025).domains(&tads);
ax.coverage(&pos, &depth).min_depth(20.0);
ax.phylo_tree(newick); // phylo_tree_circular(newick)
ax.oncoprint(&genes, samples, &events);
ax.mutation_lollipop(393.0, &domains, &mutations);
}
#![allow(unused)]
fn main() {
ax.sequence_logo(&aligned);
ax.gene_track(&genes);
ax.manhattan(chromosome, position, &p);
ax.volcano(names, &log2_fc, &p, 1.0, 1e-3, 6);
ax.embedding(&umap_x, &umap_y, cell_types);
ax.dose_response(&dose, &response);
ax.kaplan_meier([("standard", t1, e1), ("new treatment", t2, e2)]);
ax.forest_plot(studies, hr, low, high, 1.0).summary_last(true);
fig.clustermap(genes, samples, &expression);
}
Code of this example · cargo run --release -p plot-biology
3D biology: DNA, molecules, cells
A DNA double helix with base pairs colored by base and a marked TATA box, real structures from the Protein Data Bank (the B-DNA dodecamer 1BNA as ball-and-stick with CPK colors, the protein crambin 1CRN as a backbone tube colored from N- to C-terminus), a cell (translucent membrane, nucleus with nucleolus, mitochondria, vesicles, ribosomes), an organoid of cells colored by a marker gene, and single-cell clusters on a 3D UMAP.
Proteins: ubiquitin (PDB 1UBQ) and crambin (1CRN) as cartoons (helices as ribbons, strands as arrows, from the PDB HELIX/SHEET records), ubiquitin colored from N- to C-terminus, its Ramachandran plot from the backbone dihedrals, and isosurfaces (marching tetrahedra) of a density around crambin and of a nucleus with its nucleolus.
#![allow(unused)]
fn main() {
ax.molecule(Molecule::from_pdb(&pdb)).style(MolStyle::Cartoon);
let angles = molecule.phi_psi(); // (φ, ψ, residue)
ax.ramachandran(&phi, &psi);
ax.isosurface_fn(|x, y, z| density(x, y, z), bounds, 64, 0.55);
ax.isosurface(&volume, [nx, ny, nz], bounds, level); // microscopy / CT stacks
}
#![allow(unused)]
fn main() {
ax.dna_helix("ATGCGTATAAAAGCC").highlight(5..11, "#ffd400", Some("TATA box"));
ax.molecule(Molecule::from_pdb(&pdb)).style(MolStyle::BallAndStick);
ax.molecule(Molecule::from_pdb(&pdb)).style(MolStyle::Backbone).coloring(MolColor::Rainbow);
ax.ellipsoid([0.0, 0.0, 0.0], [10.0, 8.0, 6.0]).opacity(0.16); // membrane
ax.spheres3d(&x, &y, &z, [1.0]).values(&expression, Colormap::Viridis);
ax.embedding3d(&umap1, &umap2, &umap3, cell_types);
ax.rotate(Axis3::X, 30.0);
}
Molecules are read from PDB (ATOM/HETATM) or XYZ text; bonds are found
from covalent radii with a spatial grid (linear time). Styles: ball-and-stick,
sticks, space-filling and backbone; colors by element, chain or along the
chain. Structures open with their longest extent across the screen
(principal axes) and far parts fade into the background for depth.
Turning the scenes
cargo run --release -- --window opens the figure in a window: drag to
turn, wheel to zoom, X/Y/Z to rotate by 15° around that axis
(Shift+key the other way), R to reset, hover an atom or base pair for its
name. In code: ax.rotate(Axis3::Z, 15.0), ax.roll(..),
ax.camera(azimuth, elevation); rotate.gif is recorded that way.
Code of this example · cargo run --release -p plot-biology-3d
Charts for engineers
An FFT amplitude spectrum, the spectrogram of a chirp with a steady tone, the Nyquist plot of a second-order system, impedances on a Smith chart, and a Bode plot (magnitude and unwrapped phase) of two transfer functions.
Streamlines of a flow around a cylinder and of a dipole field (colored by speed, log scale when it spans decades), a ternary diagram of soil texture, a 3D waterfall of vibration spectra, an SPC control chart (±1/2/3σ zones, Western Electric rules 1 and 2), a Pareto chart, 3D vectors of the field around a wire and 3D bars.
#![allow(unused)]
fn main() {
ax.streamplot(|x, y| (u(x, y), v(x, y)), (-3.0, 3.0), (-2.0, 2.0), 28);
ax.ternary(&sand, &silt, &clay).names("sand %", "silt %", "clay %");
ax.waterfall3d(&freq, &time, spectra);
ax.control_chart(&diameters);
ax.pareto(causes, counts);
ax.quiver3d(points, vectors);
ax.bar3d(months, sites, energy);
}
#![allow(unused)]
fn main() {
ax.spectrum(&signal, fs);
ax.spectrogram(&signal, fs, 512, 64);
let w = logspace(0.01, 100.0, 400);
let h = freq_response(&[1.0], &[1.0, 0.4, 1.0], &w); // 1 / (s² + 0.4s + 1)
ax.nyquist(&h);
ax.smith(&impedances);
fig.bode("1/(s²+0.4s+1)", &w, &h);
}
Code of this example · cargo run --release -p plot-engineering
Charts for traders
Candlesticks on a trading-day axis (no weekend gaps) with the Ichimoku cloud and VWAP, a volume profile on the same price axis (point of control and value area), stochastic, ATR, order book depth, drawdown of an equity curve and a Renko chart. Linked crosshair and zoom work across the panels in a window.
Order flow and options: an order-book liquidity heatmap with the traded price, footprint bars (bid × ask per price level, imbalances, point of control), a market profile (TPO letters, POC, value area), the payoff of an iron condor and a covered call at expiry and before it (Black–Scholes), and an implied volatility surface.
#![allow(unused)]
fn main() {
ax.liquidity_heatmap((t0, t1), (p0, p1), &depth);
ax.footprint(bars, 0.25);
ax.market_profile(&half_hour_ranges, 1.0);
ax.option_payoff(&[OptionLeg::Put { strike: 95.0, premium: 2.0, qty: -1.0 }, /* … */], (82.0, 118.0), 30.0, 0.22, 0.03);
ax.volatility_surface(&strikes, &maturities, &iv);
}
#![allow(unused)]
fn main() {
let x = ax.trading_axis(×, "%d %b");
ax.candlestick(&x, &open, &high, &low, &close);
ax.ichimoku(&x, &high, &low, &close);
ax.vwap(&x, &high, &low, &close, &volume);
profile.volume_profile(&close, &volume, 24);
osc.stochastic(&x, &high, &low, &close, 14, 3);
book.depth_chart(&bids, &asks);
dd.drawdown(&x, &equity);
renko.renko(&close, 2.0);
}
Code of this example · cargo run --release -p plot-trading
Drawing tools
The drawing tools of trading platforms, in code or with the mouse:
- trend lines and rays (continued to the edge of the plot);
- price levels, with the value in a tag on the price axis;
- Fibonacci retracements: the 0, 23.6, 38.2, 50, 61.8, 78.6 and 100 % levels, with their prices, over shaded bands.
Drawings keep their data positions when you zoom or pan, and they are saved with the chart (PNG, SVG, PDF, HTML).
#![allow(unused)]
fn main() {
ax.candlestick(x, open, high, low, close);
ax.ray((5.0, 98.3), (101.0, 123.9)).label("support line");
ax.price_level(152.1).label("resistance");
ax.fib_retracement((0.0, 98.3), (53.0, 152.1));
}
In a window (cargo run --release -- --show), you draw with the mouse:
| Key | Then |
|---|---|
T | drag from one point to another: trend line |
L | click at a price: price level |
F | drag from the start of a move to its end: Fibonacci retracement |
| Backspace | takes back the last drawing |
A dashed preview follows the mouse while you drag. The same drawings are
available in the JSON spec ("drawings": [{"type": "fib", "from": [x, y], "to": [x, y]}, …]) and in Python (ax.trendline, ax.price_level,
ax.fib_retracement).
Code of this example · cargo run --release -p plot-drawing-tools
Volume files: NIfTI, DICOM, VTK, MetaImage
A head phantom (the 3D Shepp–Logan ellipsoids, in Hounsfield-like units,
with one octant cut away) is written as a NIfTI file and as a DICOM
series of 96 slices, read back with VolumeData::read and rendered.
- Lighting: the left and middle images differ only in lighting.
The value gradient gives every surface in the volume diffuse light and
a highlight, so the cut-away shows its shape. Lighting is on by
default;
.shading(false)turns it off. - Physical units: voxel spacing (1.5 mm in plane, 2 mm between slices) and the origin come from the files, so the volume keeps its proportions.
- Speed: both files (128 × 128 × 96 voxels) are read in about 4 ms each; the three renderings are saved in about 115 ms.
#![allow(unused)]
fn main() {
use dataviz::plot::volume_file::VolumeData;
let scan = VolumeData::read("head.nii.gz")?; // .nii .nii.gz .vtk .mhd .mha .dcm, or a DICOM directory
ax.volume_data(&scan)
.range(-1000.0, 1000.0) // bone window (HU)
.threshold(0.6)
.colormap(Colormap::Magma);
}
| Format | Read |
|---|---|
NIfTI-1 and NIfTI-2 (.nii, .nii.gz) | any data type, either byte order, intensity scaling; for 4D files the first volume |
DICOM (a directory of slices, or a multi-frame .dcm) | sorted along the slice normal, rescale slope and intercept applied; uncompressed transfer syntaxes |
VTK legacy structured points (.vtk) | ASCII or binary, the first scalar array |
MetaImage (.mhd + raw, .mha) | plain or zlib-compressed |
In Python: ax.volume("head.nii.gz"). In a JSON spec:
{"type": "volume", "path": "scans/ct/"}.
Code of this example · cargo run --release -p plot-volume-files
Business and editorial charts
A bullet chart of KPIs against targets, a dumbbell chart, a slope chart, a bump chart of league positions, a waffle chart, a marimekko (mosaic) chart, a chord diagram of migration flows, a streamgraph and a horizon chart of six stocks.
#![allow(unused)]
fn main() {
ax.bullet(kpis, values, targets, &ranges);
ax.dumbbell(countries, &y2000, &y2023).labels("2000", "2023");
ax.slope(brands, &share_2020, &share_2025, "2020", "2025");
ax.bump(teams, seasons, &ranks);
ax.waffle(sources, shares);
ax.marimekko(regions, segments, &sales);
ax.chord(regions, &flows);
ax.streamgraph(&weeks, &[("Pop", pop), ("Rock", rock)]);
ax.horizon(&days, &[("AAA", returns_a), ("BBB", returns_b)]);
}
Shapes of one color are merged into one path and curves are flattened, so each chart is a handful of nodes for the rasterizer.
Code of this example · cargo run --release -p plot-business
Lines, points and bars
Line styles
Solid, dashed, dotted, dash-dot and long-dash lines with an outside legend.
Code of this example · cargo run --release -p plot-line
Markers, steps and smoothing
Point markers, step lines, monotone spline smoothing and marker-only series.
Code of this example · cargo run --release -p plot-markers-steps-smooth
Area and fill between
Filled area under a curve and the band between two curves.
Code of this example · cargo run --release -p plot-area-fill
Stacked areas
Stacked and 100 % stacked area charts side by side.
Code of this example · cargo run --release -p plot-stacked-area
Scatter and bubble charts
Colormapped scatter with a colorbar and regression line; bubble chart on a log axis.
Code of this example · cargo run --release -p plot-scatter-bubble
Bar charts
Grouped, stacked, percent (horizontal) and negative-value bar charts with value labels.
Code of this example · cargo run --release -p plot-bars
Stem and waterfall charts
A stem plot and a waterfall chart with a total.
Code of this example · cargo run --release -p plot-stem-waterfall
Error bars and confidence bands
Measurements with error bars over a model line with a ±1 band.
Code of this example · cargo run --release -p plot-errorbars-band
Vector field and function plots
Colored quiver plot and adaptively sampled function plots.
Code of this example · cargo run --release -p plot-quiver-function
Statistics
Histograms, KDE and ECDF
Overlapping density histograms with a KDE line; cumulative step histogram and ECDF.
Code of this example · cargo run --release -p plot-histograms
Box and violin plots
Notched box plots with means and outliers next to violin plots.
Code of this example · cargo run --release -p plot-box-violin
Distributions
Strip plot (jittered points), swarm plot (points side by side without overlap), a ridgeline of monthly temperatures (densities on overlapping rows) and a Q-Q plot that shows incomes are not normally distributed.
#![allow(unused)]
fn main() {
ax.strip([("Mon", &mon), ("Tue", &tue)]);
ax.swarm([("Mon", &mon), ("Tue", &tue)]);
ax.ridgeline(months); // (name, values) per row
ax.qq(&incomes); // against the normal distribution
}
Code of this example · cargo run --release -p plot-distributions
Facets and pair plots
Figure::facet_wrap draws one plot per group in a grid with shared ranges
(tick labels on the outer plots only, all plots the same size);
Figure::pair_plot draws the scatter matrix of several variables with
histograms on the diagonal.
#![allow(unused)]
fn main() {
fig.facet_wrap(cities, 3, |ax, data| { ax.line(&months, data); });
fig.pair_plot([("length", &length), ("weight", &weight), ("phase", &phase)]);
}
Code of this example · cargo run --release -p plot-facets
2D histogram and hexbin
Density of 20 000 points as a 2D histogram and as hexagonal bins.
Code of this example · cargo run --release -p plot-hist2d-hexbin
Finance and time
Candlestick chart
Daily candlesticks on a time axis with a 10-day moving average.
Code of this example · cargo run --release -p plot-candlestick
Technical indicators
Candlesticks with Bollinger bands, the RSI with its 30/70 levels and the MACD with its histogram, in panels that share the time axis and line up (in a window they also share a crosshair and zoom together), plus Heikin-Ashi candles.
#![allow(unused)]
fn main() {
ax.candlestick(&t, &open, &high, &low, &close);
ax.bollinger(&t, &close, 20, 2.0);
rsi_axes.rsi(&t, &close, 14);
macd_axes.macd(&t, &close, 12, 26, 9);
}
The indicator values are available as functions too:
dataviz::plot::stats::{sma, ema, bollinger, rsi, macd, heikin_ashi}.
Code of this example · cargo run --release -p plot-indicators
Time series
Hourly data on a time axis, bars on a secondary y-axis, reference line and shaded span.
Code of this example · cargo run --release -p plot-time-series
Gantt chart
Project plan with progress on a time axis and a “today” marker.
Code of this example · cargo run --release -p plot-gantt
Parallel coordinates and calendar heatmap
Iris-like data in parallel coordinates and a year of daily values as a calendar.
Code of this example · cargo run --release -p plot-parallel-calendar
Grids, fields and 3D
Heatmap (correlation matrix)
Annotated correlation matrix with a diverging colormap and colorbar.
Code of this example · cargo run --release -p plot-heatmap
Contour plots
Labelled contour lines and filled contours with a colorbar.
Code of this example · cargo run --release -p plot-contour
Image display
An RGBA image (Mandelbrot set) shown on axes.
Code of this example · cargo run --release -p plot-image
3D charts: surface, trajectory, scatter and mesh
A lit surface, the Lorenz attractor as a 3D line colored by time, and points inside a translucent ellipsoid with perspective. All 3D series of a plot share one scene (one box, one camera, one depth order), so they hide each other correctly.
#![allow(unused)]
fn main() {
ax.surface_fn(|x, y| (x * x + y * y).sqrt().sin(), (-8.0, 8.0), (-8.0, 8.0), 60);
ax.line3d(&x, &y, &z).values(&t).colormap(Colormap::Plasma);
ax.scatter3d(&x, &y, &z).values(&z).colormap(Colormap::Turbo);
ax.ellipsoid([0.0, 0.0, 0.0], [3.2, 2.2, 1.7]).opacity(0.2);
ax.camera(-60.0, 30.0).rotate(Axis3::X, 20.0).perspective(0.4);
}
Volume rendering
A 3D grid of values (densities, CT/MRI scans, simulation fields) seen through: rays cast through the grid for every pixel, low values transparent, higher ones glowing in the colormap — or the maximum along each ray (maximum intensity projection). A 96³ grid draws in about 60 ms.
#![allow(unused)]
fn main() {
ax.volume(values, [nx, ny, nz]) // values[x + nx·(y + ny·z)]
.extent((-1.0, 1.0), (-1.0, 1.0), (-1.0, 1.0))
.opacity(0.35)
.threshold(0.1)
.colorbar("density");
ax.volume(values, dims).mode(VolumeMode::MaxIntensity);
}
Turning the scene
The camera turns freely around the x, y and z axes (a rotation matrix, no
gimbal lock): ax.rotate(Axis3::Y, 30.0), ax.roll(10.0),
ax.camera(azimuth, elevation) or ax.set_camera(Camera::principal(&points)).
In a window (cargo run --release -- --window) drag to turn, use the wheel
to zoom, X/Y/Z to rotate by 15° around that axis (Shift+key the
other way) and R to reset. GUI and WebAssembly apps do the same with
fig.pan_by, fig.zoom_at and fig.rotate_view.
Code of this example · cargo run --release -p plot-three-d
Maps
Maps
A world choropleth of population density (log colors, colorbar, graticule) with flight routes along great circles, and the world in the Robinson, Natural Earth, equal-area Equal Earth and Mollweide, equirectangular and Mercator projections, conic maps of countries and polar maps. The country outlines, ISO codes, population and GDP come with dataviz (Natural Earth 1:110m, public domain); hovering a country in a window shows its name and value.
Conic and polar maps
Countries and continents on conic projections: Albers equal-area for the
USA (Projection::USA) and Lambert conformal for Europe
(Projection::EUROPE), each framed with map_bounds. The poles are shown
in the stereographic and Lambert azimuthal equal-area projections. Shapes
that cross the meridian opposite the map’s centre are cut there, and long
edges are drawn as curves.
#![allow(unused)]
fn main() {
ax.map(Projection::USA);
ax.choropleth(density).log(true);
ax.map_bounds((-126.0, -66.0), (23.0, 50.0));
ax.map(Projection::Stereographic { lon: 0.0, lat: 90.0 }); // the Arctic
}
Globe
ax.globe(lon, lat) shows the Earth from space (orthographic projection):
the far side is cut away along the rim, maps, routes and points follow.
ax.globe_center(lon, lat) turns it, so a spinning globe is a record
loop.
#![allow(unused)]
fn main() {
ax.globe(30.0, 35.0);
ax.choropleth(population).log(true).graticule(30.0);
ax.geo_line([28.98, -73.94], [41.01, 40.67]); // great circle
fig.record("globe_spin.gif", 20.0, 60, |f, k| {
f.axes().globe_center(k as f64 * 6.0, 20.0);
})?;
}
States and provinces of any country (feature regions: Natural Earth
1:10m admin-1, colored here by their area computed from the outlines), a
flow map along great circles, a hexbin density map and OpenStreetMap tiles
as a basemap (cargo run --release -- --fetch-tiles downloads the few
tiles once into tiles/, following the OSM tile usage policy).
#![allow(unused)]
fn main() {
ax.region_map("TUR", [("TR-34", 15.7), ("TR-06", 5.8)]); // ISO 3166-2 codes or names
ax.geo_flows(&[(28.8, 41.0, -73.8, 40.6, 9.0)], &["IST–JFK"]);
ax.geo_hexbin(&lon, &lat).gridsize(45);
ax.basemap((28.9, 29.1), (40.98, 41.1), 12, tile_dir("tiles"), "© OpenStreetMap contributors");
}
#![allow(unused)]
fn main() {
ax.map(Projection::Robinson);
ax.choropleth([("DEU", 83.2), ("TUR", 85.3), ("JP", 124.5), ("Brazil", 203.1)])
.colorbar("population [M]");
ax.geo_line([28.98, -74.0], [41.01, 40.7]); // great circle
ax.geo_scatter([28.98, -74.0], [41.01, 40.7]);
}
Regions or provinces from a GeoJSON file:
ax.geo_shapes(&geo::read_geojson(&text)?, values, "name").
Code of this example · cargo run --release -p plot-maps
Parts, flows and polar
Pie and donut charts
Pie with exploded slice and labels; donut with centre text.
Code of this example · cargo run --release -p plot-pie-donut
Treemap and sunburst
Hierarchical data as a squarified treemap and as a sunburst.
Code of this example · cargo run --release -p plot-treemap-sunburst
Funnel and gauge
A sales funnel and a gauge with colored ranges.
Code of this example · cargo run --release -p plot-funnel-gauge
Sankey diagram
Energy flows between sources, carriers and uses.
Code of this example · cargo run --release -p plot-sankey
Network graphs
A force-directed network with node groups, and the imports between the modules of five packages as an arc diagram and with hierarchical edge bundling (edges bent through their package, so related links run together).
#![allow(unused)]
fn main() {
ax.arc_diagram(&names, edges.clone()).groups(groups.clone()).group_names(packages);
ax.edge_bundling(&names, groups, edges).group_names(packages).tension(0.85);
}
Code of this example · cargo run --release -p plot-network
Polar, radar and rose charts
Polar curves, a radar (spider) chart and a wind rose.
Code of this example · cargo run --release -p plot-polar-radar
Axes, layout, text and style
Subplots with a shared x-axis
A 2 × 2 grid of plots sharing the x limits.
Code of this example · cargo run --release -p plot-subplots-shared
Logarithmic scales
Log-log axes with minor ticks and a symmetric-log axis.
Code of this example · cargo run --release -p plot-log-scales
Broken axes
Axis::break_at(from, to) leaves an empty range out of an axis: one very
large bar next to small ones stays readable, and a recording with a long
outage does not waste the plot on the gap. The break is marked with a gap
and // on the axis, ticks are placed per segment and lines do not jump
over it.
#![allow(unused)]
fn main() {
ax.y_axis().break_at(25.0, 920.0);
}
Code of this example · cargo run --release -p plot-broken-axis
Tick formats
SI-prefixed and percent tick labels.
Code of this example · cargo run --release -p plot-formats
Annotations
Arrow, text, shaded band, rectangle and reference line.
Code of this example · cargo run --release -p plot-annotations
Math notation
$...$ in any text (titles, axis labels, legends, annotations) is typeset
from a TeX subset: superscripts and subscripts, fractions, roots, accents,
Greek letters, big operators, function names, \mathrm, \mathbb, … It is
laid out into ordinary text and lines, so PNG, SVG, PDF and the GPU backend
all show the same result.
#![allow(unused)]
fn main() {
ax.y_label(r"$\sigma^2$ [$\mathrm{m^2\,s^{-2}}$]");
ax.text(0.5, 0.5, r"$\int_0^\infty e^{-x^2}\,dx = \frac{\sqrt{\pi}}{2}$");
}
Code of this example · cargo run --release -p plot-math
Text in any language
Labels in Chinese, Japanese, Korean, Arabic, Hebrew, Hindi, Thai, Greek, Turkish and Ukrainian, plus color emoji. Characters the theme font lacks come from system fonts (scanned once, the first time they are needed), Arabic and Hebrew are laid out right to left and shaped, and emoji are drawn from a color emoji font. Latin text keeps a fast path.
The fonts come from the system: on Linux, for example, fonts-noto-cjk,
fonts-noto-core and fonts-noto-color-emoji. In SVG output the text is
written as text, so the viewer picks its own fonts.
Code of this example · cargo run --release -p plot-international
Accessibility
Charts for everyone:
- SVG, PDF and HTML output carry an accessible name and a description that
screen readers read:
fig.alt_text()generates it from the plots, axes, ranges and series, or set your own withfig.description(..). fig.color_warnings()lists series whose colors are hard to tell apart, normally or with protanopia, deuteranopia or tritanopia.Pixels::simulate(Cvd::Deuteranopia)shows a chart as people with a color vision deficiency see it.
Red, green and orange lines — normal, deuteranopia, protanopia, tritanopia:
The same chart with the colour-blind safe Okabe–Ito palette:
Output:
Alt text: Red / green / orange. Line chart; quarter from 0.850 to 4.150; sales [k€] from 10.55 to 23.77. Series: north (11.148 to 14.988); south (12.097 to 19.997); east (11.94 to 23.17).
warning: "north" and "south" look alike with deuteranopia
warning: "south" and "east" look alike with protanopia
with Okabe–Ito: 0 warnings
Code of this example · cargo run --release -p plot-accessibility
Themes
The same chart in every built-in theme (Theme::presets()).
Theme::high_contrast() is for low vision and projectors: black on white,
heavier lines, larger text and dark colors each at least 4.5:1 against
white.
Code of this example · cargo run --release -p plot-themes
Interactivity
Windows
fig.show("title") opens a window; fig.show_live("title", fps, update)
redraws as data arrives.
| Mouse / key | Action |
|---|---|
| wheel, drag, right-drag | zoom at the cursor, pan, zoom to a box |
C, H | crosshair with axis values (linked across plots), hover tooltip |
| click a legend row | hide or show the series |
| range slider | drag to pan, drag its edges to zoom |
| Shift+drag, Ctrl+drag | measure Δx, Δy and %, select a box (fig.selection()) |
A, R | auto-scale y to the visible data, reset |
S, Shift+S, Ctrl+C, V | save PNG, SVG/PDF, copy, record a GIF |
3D: drag, wheel, X/Y/Z | turn, zoom, rotate 15° around an axis (Shift: back) |
HTML pages
fig.save("chart.html") writes one self-contained file: hover readouts,
a crosshair, linked cursors, legend toggling, zoom (mouse wheel at the
cursor; over an axis only that axis), pan (drag), reset (double click or
the Reset button), PNG download — and 3D plots that turn with the mouse.
Linked brushing
With fig.link_brushing(true) a box selected in one plot (Ctrl+drag in a
window, Shift+drag in an HTML page) highlights the same rows in every plot:
row i of each scatter, line, bar or price series with the same number of
points is the same record. fig.brushed() returns the selected row
indices (for example to filter a table in your app), and
fig.brush(plot, x_range, y_range) or fig.brush_rows(n, rows) select
from code — the highlight then appears in PNG, SVG and PDF output too.
#![allow(unused)]
fn main() {
use dataviz::prelude::*;
let (price, volume, ret) = (vec![1.0, 2.0, 3.0], vec![5.0, 3.0, 4.0], vec![0.1, -0.2, 0.05]);
let mut fig = Figure::new(900, 400);
fig.grid(1, 2).link_brushing(true);
fig.at(0, 0).scatter(price.clone(), volume);
fig.at(0, 1).scatter(price, ret);
fig.save("linked.html")?;
Ok::<(), dataviz::Error>(())
}
Your own GUI or web page
The same interaction without a window: render into pixels and forward the events.
fig.render_into(&mut pixels)?; // RGBA for a texture
fig.zoom_at(x, y, 0.8); // wheel
fig.pan_by(x, y, dx, dy); // drag (turns 3D plots)
if let Some(h) = fig.hover(x, y) { show(h.text); }
fig.click(x, y); // legend rows
fig.rotate_view(plot, Axis3::Y, 15.0);
fig.reset_view();
Examples: egui, WebAssembly (live demo).
3D
All 3D series of a plot share one scene — one box, one camera, one depth
order — so they hide each other correctly. Faces are lit, spheres and tubes
shaded, far parts can fade (depth_cue).
ax.surface_fn(|x, y| (x * y).sin(), (-3.0, 3.0), (-3.0, 3.0), 60);
ax.scatter3d(&x, &y, &z).values(&v).colormap(Colormap::Turbo);
ax.line3d(&x, &y, &z);
ax.spheres3d(&x, &y, &z, [0.5]);
ax.ellipsoid([0.0, 0.0, 0.0], [3.0, 2.0, 1.0]).opacity(0.2);
ax.isosurface(&volume, [nx, ny, nz], bounds, level);
ax.quiver3d(points, vectors);
ax.bar3d(columns, rows, values);
ax.camera(-60.0, 30.0).rotate(Axis3::X, 20.0).roll(5.0).perspective(0.4);
Molecules and DNA
ax.dna_helix("ATGCGTATAAAAGCC").highlight(5..11, "#ffd400", Some("TATA box"));
let ubq = Molecule::from_pdb(&std::fs::read_to_string("1ubq.pdb")?);
ax.molecule(ubq.clone()).style(MolStyle::Cartoon); // helices, strands
let angles = ubq.phi_psi(); // Ramachandran
Styles: ball-and-stick, sticks, space-filling, backbone, cartoon; colors by element, chain or along the chain. Structures open with their longest extent across the screen.
In windows, HTML pages and apps the scenes turn with the mouse (see Interactivity).
Maps
use dataviz::plot::geo::Projection;
ax.map(Projection::Robinson); // or Mercator, NaturalEarth, …
ax.choropleth([("DEU", 83.2), ("TUR", 85.3), ("Brazil", 203.1)]).colorbar("M");
ax.geo_line([28.98, -74.0], [41.01, 40.7]); // great circle
ax.geo_scatter(&lon, &lat);
ax.geo_flows(&flows, &names); // flow map
ax.geo_hexbin(&lon, &lat); // density
ax.region_map("TUR", [("TR-34", 15.7), ("Ankara", 5.8)]); // feature "regions"
ax.basemap((28.9, 29.1), (40.98, 41.1), 12, tile_dir("tiles"), "© OpenStreetMap contributors");
The world map (Natural Earth 1:110m) and, with the regions feature, the
states and provinces of every country (1:10m) are built in, with ISO codes,
names, population and GDP; geo::read_geojson reads other shapes. Tiles
come from any source you give (tile_dir reads a folder); credit the
provider.
Output
fig.save("chart.png")?; // .svg .pdf .jpg .webp .bmp .html
let bytes = fig.encode(Format::Png)?;
fig.render_into(&mut pixels)?; // RGBA, reusing the buffer
fig.print()?; // terminal: colored half blocks or Braille
fig.record("wave.gif", 30.0, 120, |fig, i| { /* change the figure */ })?; // .gif .png (APNG) .mp4 .webm
let text = fig.alt_text(); // a description for screen readers and captions
Backends
fig.backend(Backend::Auto); // CPU, all cores from 1 megapixel on
fig.backend(Backend::Cpu { threads: 1 }); // least CPU time and memory
fig.backend(Backend::Gpu); // feature "gpu"
Accessibility
SVG, PDF and HTML carry the title and a generated description;
fig.color_warnings() finds series that look alike with color vision
deficiencies and pixels.simulate(Cvd::Deuteranopia) shows the chart as
others see it.
Performance
Measured against matplotlib (Python) and the Rust libraries plotters, ruviz, kuva and charts-rs: the same charts, separate processes, medians (Intel(R) Core(TM) Ultra 7 255HX, NVIDIA GeForce RTX 5070 Ti Laptop GPU, Linux). Full results, method and the code to rerun them: dataviz-examples/benchmarks.
Compared with matplotlib: 8–53× faster for charts saved to PNG, 28× faster for a live 100 000-point chart, and 178× less memory for 10 M points.
Charts to an 800×600 PNG (one thread, time per chart):
| Chart | dataviz | plotters | ruviz | kuva | charts-rs | matplotlib |
|---|---|---|---|---|---|---|
| line, 1 000 points | 1.50 ms | 1.66 ms | 3.60 ms | 4.98 ms | 11.1 ms | 29.3 ms |
| bar, 20 bars | 0.79 ms | 0.83 ms | 3.90 ms | 3.55 ms | 2.08 ms | 41.8 ms |
| scatter, 10 000 points | 2.12 ms | 2.83 ms | 4.37 ms | 8.53 ms | 76.2 ms | 37.5 ms |
| scatter, 100 000 points | 9.88 ms | 16.6 ms | 16.9 ms | 17.4 ms | 784.5 ms | 81.8 ms |
| line, 100 000 points | 2.17 ms | 5.91 ms | 8.39 ms | 28.2 ms | 829.7 ms | 50.2 ms |
| histogram, 1 M values | 2.06 ms | 2.76 ms | 30.2 ms | 16.1 ms | 12.8 ms | 49.6 ms |
Big data (time / memory above the data itself):
| Chart | dataviz | dataviz all cores | plotters | ruviz | kuva | charts-rs | matplotlib |
|---|---|---|---|---|---|---|---|
| line, 10 M points | 129.0 ms / +7 MB | 103.1 ms / +6 MB | 481.9 ms / +315 MB | 332.5 ms / +389 MB | 2.70 s / +787 MB | fails | 533.1 ms / +1162 MB |
| scatter, 10 M points | 230.3 ms / +8 MB | 181.6 ms / +7 MB | 1.53 s / +12 MB | 1.23 s / +376 MB | 1.56 s / +788 MB | fails | 5.08 s / +910 MB |
| histogram, 100 M values | 243.5 ms / +7 MB | 235.2 ms / +6 MB | 264.6 ms / +12 MB | 3.64 s / +1915 MB | 1.64 s / +1551 MB | 1.23 s / +1533 MB | 516.6 ms / +13 MB |
Live chart (rolling window, one new point and a full redraw per frame; latency p50 / CPU per frame / memory of the process):
| Window | dataviz 1 thread | dataviz all cores | dataviz GPU | plotters | ruviz | kuva | matplotlib |
|---|---|---|---|---|---|---|---|
| 1 000 points, 800×600 | 0.77 ms / 0.77 ms / 7 MB | 0.49 ms / 2.57 ms / 8 MB | 0.67 ms / 0.47 ms / 214 MB | 0.65 ms / 0.63 ms / 14 MB | 4.66 ms / 4.67 ms / 11 MB | 5.26 ms / 5.23 ms / 27 MB | 10.1 ms / 10.1 ms / 73 MB |
| 100 000 points, 800×600 | 2.20 ms / 2.17 ms / 12 MB | 2.02 ms / 4.67 ms / 13 MB | 2.04 ms / 1.63 ms / 219 MB | 5.40 ms / 5.37 ms / 16 MB | 34.6 ms / 34.6 ms / 17 MB | 47.0 ms / 47.1 ms / 36 MB | 62.0 ms / 62.0 ms / 112 MB |
| 1 000 points, 1920×1080 | 1.69 ms / 1.70 ms / 15 MB | 0.77 ms / 5.83 ms / 17 MB | 1.39 ms / 1.23 ms / 221 MB | 1.48 ms / 1.50 ms / 18 MB | 17.4 ms / 17.4 ms / 18 MB | 18.0 ms / 18.0 ms / 33 MB | 12.4 ms / 12.6 ms / 79 MB |
| 100 000 points, 1920×1080 | 5.51 ms / 5.53 ms / 18 MB | 3.25 ms / 14.1 ms / 20 MB | 2.70 ms / 2.53 ms / 225 MB | 8.43 ms / 8.43 ms / 21 MB | 119.9 ms / 119.9 ms / 28 MB | 115.8 ms / 115.8 ms / 42 MB | 136.8 ms / 136.8 ms / 177 MB |
Animated GIF (800×600, 120 frames; time, file size):
| Animation | dataviz | plotters | ruviz | matplotlib |
|---|---|---|---|---|
| whole plot moves | 282.0 ms, 1001 KB | 1.09 s, 3227 KB | 3.00 s, 1741 KB | 5.24 s, 1119 KB |
| line grows on fixed axes | 81.0 ms, 38 KB | 2.40 s, 3257 KB | 2.91 s, 1701 KB | 5.75 s, 420 KB |
3D charts (800×600 PNG; dataviz, plotters and matplotlib on one core, PyVista on the GPU; a rotation frame is the camera turned and the image drawn again):
| Chart | dataviz | dataviz GPU | plotters | matplotlib | PyVista |
|---|---|---|---|---|---|
| surface 60² | 6.34 ms | 2.37 ms | 6.05 ms | 57.0 ms | 93.7 ms |
| surface 200² | 29.9 ms | 5.41 ms | 21.3 ms | 146.2 ms | 101.0 ms |
| scatter 10,000 | 2.81 ms | 2.00 ms | 3.19 ms | 96.3 ms | 89.2 ms |
| scatter 1,000,000 | 147.0 ms | 39.9 ms | 170.3 ms | 5.71 s | 119.2 ms |
| line 100,000 (Lorenz) | 9.93 ms | 3.79 ms | 8.41 ms | 59.3 ms | 87.8 ms |
| molecule 1BNA (486 atoms) | 3.35 ms | 2.31 ms | 1.91 ms | 37.6 ms | 82.1 ms |
| rotation frame: surface 60² | 5.10 ms | 0.45 ms | 4.98 ms | 25.0 ms | 0.55 ms |
| rotation frame: molecule | 2.13 ms | 0.46 ms | 0.88 ms | 11.4 ms | 0.61 ms |
| GIF, 90 frames turning | 885.7 ms, 3949 KB | 665.9 ms, 3453 KB | 2.80 s, 4544 KB | 7.38 s, 5713 KB | 4.14 s, 3441 KB |
What makes it fast: the scene is drawn straight into the output buffer by dataviz’s own anti-aliased rasterizer; dense lines become one pixel-column envelope and dense scatter plots an occupancy grid, so time and memory stay flat as the data grows; data passed to a series is not copied; glyphs and markers are cached as bitmaps; histograms use SIMD binning. Animations store only the changed part of each frame. On the web the same renderer compiled to WebAssembly draws a 960×520 live chart with 2 × 3 000 points in about 1.7 ms.
In 3D dataviz is 35–52× faster than matplotlib for scatter plots, 5–23× for surfaces and 4–9× for lines, molecules and rotation frames; it draws a turning GIF 3.2× faster than plotters and 7.4× faster than PyVista and is first (on the CPU or the GPU) for both surfaces and for scatter plots up to a million points, with lighting, depth order and anti-aliasing. plotters is faster for the long 3D line and the molecule: it draws 1-pixel lines and flat circles without depth sorting or lighting, while dataviz shades every atom as a lit sphere. PyVista (VTK) keeps the scene on the GPU and turns it in 0.6 ms per frame against dataviz’s 2–5 ms (still 200–500 frames per second), but needs 80–100 ms to save an image and about 280 MB of memory.
Where it is not first: for a tiny live chart (1 000 points) on a single thread plotters is 0.1–0.2 ms faster per frame; dataviz on all cores is the fastest there. The GPU backend needs the least CPU time but ~240 MB of driver memory and ~0.3 s to start, so the default stays on the CPU.
Python
pip install dataviz-rs
import numpy as np
import dataviz as dv
x = np.linspace(0, 10, 100_000)
fig = dv.Figure(900, 500, title="Signal", theme="light")
ax = fig.axes()
ax.line(x, np.sin(x), label="sin").set(x_label="t [s]", legend="upper_right")
fig.save("signal.png") # .svg .pdf .html …
fig # Jupyter shows it inline
NumPy arrays of any numeric type are read in place in one pass. Polars,
pyarrow and Arrow-backed pandas columns are read straight from their Arrow
buffers (the Arrow PyCapsule interface: no NumPy, no float64 copy in
between; missing values become gaps). Lists and anything else NumPy accepts
work too. 10 million rows from Polars take ~30 ms, 9–60× faster than
going through NumPy.
Methods: line, scatter, area, fill_between, bar, barh, hist,
boxplot, violin, swarm, raincloud, ridgeline, kde, heatmap,
pie, candlestick, surface, scatter3d, line3d, molecule,
hline, vline, text, set, camera, rotate — and
chart(type, **fields) for all 40 spec types (dv.chart_types()).
fig = dv.Figure(1200, 450).grid(1, 3)
fig.subplot(0, 0).boxplot({"control": a, "treated": b})
fig.subplot(0, 1).chart("roc", labels=y_true, scores=y_score)
fig.subplot(0, 2).molecule("1ubq.pdb", style="cartoon").rotate("y", 30)
Interactive in Jupyter
fig.interactive() shows the interactive page in the notebook: hover
readouts, zoom (wheel) and pan (drag), turning 3D plots, and linked
brushing — rows selected with Shift+drag in one plot are highlighted in all
of them. With anywidget installed (pip install "dataviz-rs[widget]") it is a widget
whose brushed trait follows the selection, also kept by the figure:
fig = dv.Figure(1100, 420).grid(1, 2).link_brushing()
fig.subplot(0, 0).scatter(df.price, df.volume)
fig.subplot(0, 1).scatter(df.price, df.returns)
w = fig.interactive()
w # select points with Shift+drag
df.iloc[fig.brushed()] # the selected rows
fig.save("selection.png") # highlighted in saved images too
Without anywidget the same page is shown, without the link back to Python.
fig alone still displays a PNG (light notebooks, nbviewer, GitHub).
Speed against matplotlib (same process, 800×600 PNG): 21× for a 1 000-point line, 17× for a 1 M-value histogram, 11× for a 1 M-point scatter, 7× for a 3D surface.
Claude and MCP
The Claude Code plugin gives Claude all of these charts: it draws from your data, CSV/JSON files and PDB structures, looks at the image, refines it and shows it.
/plugin marketplace add dataviz-rs/dataviz
/plugin install dataviz@dataviz
Ask “plot bench.csv and compare the branches”, “show 1UBQ as a cartoon
with its Ramachandran plot”, or use /dataviz:plot and /dataviz:molecule.
The plugin runs the dataviz-mcp server, which works with any MCP client:
cargo install dataviz-mcp
{ "mcpServers": { "dataviz": { "command": "dataviz-mcp" } } }
Tools: plot (a figure from a JSON spec — 40 chart types, layers),
plot_file, molecule, chart_types. The spec format is the same as
dataviz::plot::spec (feature spec) and Python’s dataviz.from_spec.