Skip to content

Plot Types

cplots ships five plot types, each backed by a dedicated data container.

XYPlot

Generic x/y line plot. Accepts one or many traces.

Multiple traces with a shared x axis:

PKSpectrum

Matter power spectrum P(k). Log-log axes, x in h/Mpc, y in (Mpc/h)³.

Multiple redshifts on the same axes:

Secondary multipole axis

Pass secondary_x_axis=cplots.multipole_axis(chi=...) to show the corresponding CMB multipole ℓ ≈ k · χ on the top x-axis. chi is the comoving distance in the same units as k (typically Mpc/h):

ClSpectrum

CMB angular power spectrum C_ell. Linear x, log y.

Secondary wavenumber axis

Pass secondary_x_axis=cplots.wavenumber_axis(chi=...) to show the corresponding wavenumber k ≈ ℓ / χ on the top x-axis:

BackgroundEvolution

Cosmological background quantities against redshift.

TrianglePlot

MCMC posterior corner plot.

XYZColored

XY plot where each curve is color-coded by a scalar Z value — useful for parameter sweeps.

XYZColoredGrid

Grid of XYZColored panels sharing a common Z axis. Use shared_colorbar=True to normalise all panels to the same color scale and draw a single colorbar.

Single shared colorbar:

Auto-layout computes ncols = ceil(sqrt(N)) when nrows/ncols are not given. Override with explicit nrows and ncols for full control.

Residuals

Any plot can produce a residual view via two methods on the plot object:

  • plot.residuals() — returns a new XYPlot with residual traces.
  • plot.with_residuals() — returns a ResidualFigure with two stacked panels sharing an x-axis.

Standalone residuals

mode="relative" gives (y − y_ref) / y_ref — the most common choice for comparing models where the absolute scale varies.

mode="absolute" is useful when you care about the raw difference in the same units as the original y-axis.

Two-panel stacked figure

with_residuals() stacks the main plot and its residuals into a single figure with a shared x-axis. The height_ratio argument controls panel proportions.