Home
A backend-agnostic plotting library.
Write your analysis once; render using matplotlib, plotly, altair or ultraplot with a single flag.
No lock-in to any rendering engine.
How it works¶
Every plot flows through the same layers, whether it starts from arrays or from a Boltzmann/dark-energy solver:
flowchart TD
raw["Arrays · DataFrames · xarray · GetDist"]
solver["Solver results<br/>CLASS · CAMB · eft4py"]
obs["<b>Observables</b><br/>one vocabulary, with units"]
data["<b>PlotData</b><br/>immutable input containers"]
spec["<b>PlotSpec</b><br/>backend-agnostic IR"]
backend["<b>Backend</b><br/>matplotlib · plotly · altair · ultraplot"]
solver -- as_observables --> obs
raw -- to_plot_data --> data
obs --> data
data -- "Plot.spec()" --> spec
spec -- "render · show · save" --> backend
Plot subclasses never import backends. Backends never import plot subclasses. Swap the backend at call time, via a context manager, or globally — the plot code stays unchanged.
Features¶
-
Plot types
General:
XYPlot·XYZColored·XYZColoredGrid·PhasePortrait. Cosmology:PKSpectrum·ClSpectrum·PrimordialSpectrum·BackgroundEvolution·BackgroundPanels·ThermodynamicsEvolution. Inference:TrianglePlot·PosteriorBands. Residuals:ResidualFigure. -
Four backends
Publication figures via matplotlib or ultraplot, interactive HTML via plotly, Vega-Lite JSON via altair.
-
Multi-panel figures
Compose plots with
(a | b) / c, or an explicit grid with colspan/rowspan, shared axes and custom column/row ratios. -
LaTeX labels
Labels, including the defaults like
$P(k)$, render as math in matplotlib; plotly shows Unicode, or MathJax withlatex_labels=True. -
Styles
Chainable, immutable formatting and a
Stylecascade. Every plot starts fromcplots.DEFAULT: Computer Modern, FiveThirtyEight colours, inward ticks. -
Solver adapters
CLASS / hi_class, CAMB and eft4py outputs through one vocabulary, with units tracked and converted, and code comparisons in one call.
-
Command line
Triangle plots from chains and line plots from data files, without Python:
cplots distributions triangle,cplots lines xy.