Expand description
A declarative, DataFrame-native chart library for Polars.
charcoal turns a Polars polars::frame::DataFrame into a publication-quality SVG,
standalone HTML, or PNG with a single builder chain — no browser, no Python, no C FFI.
§Feature Flags
| Feature | Enables | Extra dependency |
|---|---|---|
| (default) | SVG and HTML output | — |
static | Chart::save_png via pure-Rust resvg | resvg |
notebook | [Chart::display] inline in evcxr Jupyter | evcxr_runtime |
§Quickstart
use charcoal::{Chart, Theme};
use polars::prelude::*;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let df = CsvReader::from_path("iris.csv")?.finish()?;
let chart = Chart::scatter(&df)
.x("sepal_length")
.y("sepal_width")
.color_by("species")
.title("Iris Dataset")
.theme(Theme::Default)
.build()?;
chart.save_html("iris.html")?;
Ok(())
}§Examples
Runnable examples for every chart type live in the examples/ directory:
cargo run --example scatter_iris
cargo run --example line_timeseries
cargo run --example bar_categorical
cargo run --example histogram_distribution
cargo run --example heatmap_correlation
cargo run --example box_plot_groups
cargo run --example area_stacked§Notebook Usage
To display charts inline in an evcxr Jupyter
notebook, enable the notebook feature:
[dependencies]
charcoal = { version = "0.1", features = ["notebook"] }In your first notebook cell, load the dependency:
:dep charcoal = { version = "0.1", features = ["notebook"] }
use charcoal::Chart;Then call .display() as the last expression in any subsequent cell:
let chart = Chart::scatter(&df).x("x").y("y").build()?;
chart.display();§Repository
Structs§
- Chart
- The fully-rendered output of a
.build()call.
Enums§
- BinMethod
- Strategy used to choose the number of histogram bins.
- Charcoal
Error - Errors that can be returned by charcoal’s public API.
- Charcoal
Warning - Non-fatal diagnostics attached to a successfully-built
crate::Chart. - Color
Scale - Continuous color gradient used to encode numeric values in heatmaps.
- Dash
Style - Dash style for line and area series.
- Fill
Mode - Controls the baseline of the filled area.
- Null
Policy - How null y-values are handled in connected series (Line, Area).
- Orientation
- Bar chart orientation.
- Point
Display - Controls which individual data points are rendered on top of each box.
- Theme
- Overall visual style applied to a chart.