Skip to content

Getting Started

Installation

Install cplots with your preferred backend:

pip install cplots[matplotlib]

Available extras:

Extra Installs
matplotlib, plotly, altair, ultraplot a rendering backend
getdist, chainconsumer, anesthetic triangle-plot engines
pandas, polars DataFrame input
dynamics SciPy, for phase portraits
camb, classy, cosmo Boltzmann solver adapters (cosmo = both)
cli the cplots command-line tool
all matplotlib, plotly, altair, getdist, pandas, polars, chainconsumer, anesthetic and dynamics

Your first plot

Switching backends

plot.show(backend="plotly")
plot.save("out.html", backend="plotly")
with cplots.backend("altair"):
    plot.show()
cplots.set_backend("plotly")
plot.show()  # always uses plotly

Saving a figure

plot.save("figure.png")                     # PNG via matplotlib
plot.save("figure.html", backend="plotly")  # interactive HTML

Formatting and styles

Each formatting method returns a new plot. Every plot starts from cplots.DEFAULT (Computer Modern text and math, FiveThirtyEight colours, boxed axes with inward ticks; see the default style). Other built-in styles are cplots.PUBLICATION (serif, white background) and cplots.DARK (transparent, white foreground, neon palette), layered on top of it. Use with cplots.style(...): to style every plot inside a block. See Formatting and Styles.

Multi-panel figures

See Multi-panel Figures for full documentation.