Skip to content

Triangle plot engines — comparison

TrianglePlot supports three rendering engines: getdist, chainconsumer, and anesthetic. The engine= kwarg is the only difference between them; everything else — samples, weights, truths, title — stays the same.

Tip

Install all three at once: pip install cplots[getdist,chainconsumer,anesthetic]. getdist is the default engine when engine= is omitted.

Note

All three engines return a standard matplotlib.figure.Figure, so saving and embedding in a Figure layout work the same whichever engine drew it.

Setup

Side-by-side comparison

GetDist

ChainConsumer

Tip

Install: pip install cplots[chainconsumer]

Anesthetic

Tip

Install: pip install cplots[anesthetic]

With importance weights

All three engines accept a weights array of shape (N,).

GetDist

ChainConsumer

Anesthetic

Several chains

Pass a list/tuple of chains, or a {label: chain} dict, to overlay posteriors with a legend. A chain is an (N, D) array (columns named by parameter_names), a TriangleData, or anything cplots adapts to one, such as a getdist MCSamples. Dict keys become legend labels; list items without their own label are named Chain 1, Chain 2, ...

  • weights= takes one array for a single chain, or a sequence (by position) or dict (by label) with one entry per chain.
  • parameter_names selects and orders the plotted parameters. Chains that carry their own names (TriangleData, MCSamples) may have extra columns; a chain missing a plotted parameter raises ValueError. When omitted, the parameters common to all chains are plotted.
  • An (n_chains, N, D) array is treated as a list of chains.

Registering a custom engine

Third-party engines integrate via BaseTriangleEngine. Subclass it with name= to register automatically at import time.

Once the module defining it is imported, engine="myengine" works like any built-in engine.