Seaborn vs charming: Statistical Visualization Compared
Seaborn builds expressive statistical graphics on top of Matplotlib in Python. Rust's charming brings a high-level charting API to Rust, making it easier to produce polished visualizations without manually assembling every plotting detail.
What Seaborn does
Seaborn simplifies statistical visualization by providing:
- Statistical plots (box plots, violin plots, distribution plots)
- Built-in themes and color palettes
- Automatic estimation of confidence intervals
- Faceting for multi-panel figures
- Integration with pandas DataFrames
- Regression plots with fitted lines and confidence bands
It became the preferred library for statistical graphics in Python, especially for exploratory data analysis.
What charming brings to Rust
charming is a Rust library for high-level statistical visualization:
- Statistical chart types (histograms, box plots, violin plots)
- Theme support for consistent styling
- Confidence interval estimation
- Faceting for grouped visualizations
- Composable with plotters for rendering
- Type-safe API for statistical operations
The key difference: charming provides a high-level abstraction over plotters, making it easier to create statistical visualizations while maintaining Rust's performance and type safety.
Comparison
| Feature | Seaborn (Python) | charming (Rust) |
|---|---|---|
| Box plot | sns.boxplot(data=df) | Chart::new().boxplot(data) |
| Theme | sns.set_theme('darkgrid') | Theme-based styling |
| Confidence interval | Automatic | Configurable, compile-time checked |
| Type safety | Runtime | Compile-time |
| Performance | Matplotlib backend | Native plotters rendering |
| Integration | pandas, Matplotlib, NumPy, etc. | plotters, ndarray, polars, etc. |
Example: Seaborn
import seaborn as sns
import matplotlib.pyplot as plt
sns.boxplot(data=df, x='category', y='value')
plt.savefig('boxplot.png')
Example: charming
use charming::prelude::*;
let chart = Chart::new().boxplot(data).theme(Theme::Dark);
chart.save("boxplot.png")?;
When to use each
- Seaborn in Python when you need a high-level API for statistical graphics, built-in themes, or integration with pandas and Matplotlib.
- charming in Rust when you need high-level statistical visualization with type safety and native performance.
Try it in Project Mars
Both ecosystems share one .mars document: Python cells run in a persistent interpreter, Rust cells on the replay runtime with // :dep Cargo dependencies — variables persist across cells within each language's own session.
Statistical visualization starts with correlation — compute it once per language:
# Seaborn side: corrplot-style pairwise correlations.
import pandas as pd
df = pd.DataFrame({
"x": [1.0, 2.0, 3.0, 4.0, 5.0],
"y": [2.1, 3.9, 6.2, 7.8, 10.1],
})
df.corr()
// :dep ndarray = "0.16"
use ndarray::array;
// charming renders charts; correlation is plain ndarray math.
let x = array![1.0, 2.0, 3.0, 4.0, 5.0];
let y = array![2.1, 3.9, 6.2, 7.8, 10.1];
let mx = x.mean().unwrap();
let my = y.mean().unwrap();
let cov: f64 = x.iter().zip(y.iter()).map(|(a, b)| (a - mx) * (b - my)).sum();
let corr = cov / ((x.var(0.0).unwrap() * y.var(0.0).unwrap()).sqrt() * 5.0);
println!("correlation ≈ {corr:.3}");
How Project Mars supports both
Project Mars supports both Seaborn and charming in their respective language runtimes:
- Python cells can use Seaborn with automatic figure capture to PNG
- Rust cells can use charming via Cargo dependencies with SVG/PNG output
- Both can coexist in the same
.marsnotebook - Statistical chart outputs render as rich MIME bundles in the notebook
Start with the getting started guide to explore Seaborn and charming in Project Mars notebooks.