plotters-statistical
Statistical chart primitives for plotters,
packaged as reusable series types that plug into chart.draw_series(...)
exactly like plotters' own built-in Histogram / LineSeries / CandleStick.
Each chart type is a composite element implementing plotters' Drawable +
PointCollection traits — the same pattern plotters uses internally for
CandleStick — so these feel native rather than bolted on.
plotters version: pinned to
=0.3.7. This crate mirrorsplotters' element/series extension pattern, so it depends on the exact trait signatures of one release. Bumpingplottershere is a deliberate, verified step, not an automatic caret upgrade.
Chart types
Series (plug into chart.draw_series(...)):
| This crate | Replaces (Python) | Notes |
|---|---|---|
BoxPlot / BoxPlotSeries |
matplotlib.pyplot.boxplot, seaborn.boxplot |
Tukey 1.5×IQR whiskers + outliers; vertical or horizontal |
ViolinPlot / ViolinPlotSeries |
seaborn.violinplot |
Gaussian KDE outline, optional embedded box |
RocCurve |
sklearn.metrics.RocCurveDisplay |
AUC in legend, opt-in chance diagonal + AUC shading |
PrecisionRecallCurve |
sklearn.metrics.PrecisionRecallDisplay |
AP in legend, prevalence baseline (not a diagonal) |
RegularizationPath |
scikit-learn coefficient-path plots | Color-cycled lines, log-x friendly, zero-crossing markers |
ResidualPlot |
seaborn.residplot |
Zero line + binned moving-average trend |
Ecdf |
statsmodels ECDF, seaborn.ecdfplot |
Step curve, optional DKW confidence band, complementary mode |
QqPlot |
statsmodels.qqplot, scipy.stats.probplot |
Normal quantiles + robust reference line |
CalibrationCurve |
sklearn.calibration.CalibrationDisplay |
Reliability diagram vs y = x |
GainChart |
cumulative-gain / lift charts | Gain or Lift mode with chance baseline |
Heatmap |
seaborn.heatmap (cells) |
Any matrix; configurable colormap, normalization, annotations |
Figures (own their axes / multi-panel layout; render onto a DrawingArea):
| This crate | Replaces (Python) | Notes |
|---|---|---|
CorrelationHeatmap |
seaborn.heatmap on df.corr() |
Pearson/Spearman, colorbar, cell annotations, diverging map |
MissingnessHeatmap |
missingno.matrix |
Present/absent map with per-column missing % |
PairPlot |
seaborn.pairplot |
Scatterplot matrix, hist/ECDF diagonal, optional hue |
Colormaps
GradientColorMap (viridis, magma, blues, reds, RdBu, coolwarm, grayscale, or
custom stops) plus a Normalization (linear or symmetric/diverging) drive every
value-to-color chart. Sources: matplotlib and ColorBrewer.
Design: math is separate from rendering
All numeric work lives in the stats module and has no plotters dependency,
so it is unit-tested against hand-computed reference values (NumPy/scikit-learn
equivalents) independently of any rendering:
stats::quartiles— type-7 quartiles, IQR, Tukey fences, outliersstats::kde— Gaussian KDE with a Silverman-rule default bandwidthstats::roc/stats::precision_recall— threshold sweeps, AUC / average precisionstats::correlation— Pearson & Spearman, correlation matricesstats::ecdf— ECDF + DKW band;stats::normal— inverse-normal quantilesstats::histogram— Sturges / Freedman–Diaconis / Scott / fixed binningstats::calibration/stats::gain— reliability bins, cumulative gain & lift
The series module turns those already-computed values into plotters draw
calls.
Quick start
use *;
use BoxPlotSeries;
Examples
One runnable example per chart type, plus a combined dashboard:
# series
# figures
# combined
Each writes an .svg into the working directory.
Styling
style::palette_color(i) cycles the Okabe–Ito color-blind-safe qualitative
palette (Okabe & Ito, 2008, https://jfly.uni-koeln.de/color/), shared by every
multi-series chart type. Every chart type's style struct is fully overridable —
see examples/box_plot.rs for a style override.
Origin
Built to replace hand-drawn chart code across the rust-ml-guide project:
its EDA, model-evaluation, and regularization chapters each re-implemented these
charts by hand. The v0.1 core (BoxPlot, ViolinPlot, RocCurve,
PrecisionRecallCurve, RegularizationPath, ResidualPlot) covered the named
gaps; the v0.2 additions (ECDF, Q–Q, calibration, gain/lift, generic heatmap, and
the correlation / missingness / pair-plot figures) round the package out to a
general statistical-plotting toolkit for plotters.
License
Licensed under the MIT license (LICENSE).