Reference / binference.plotting.plot_population
binference.plotting.plot_population¶
- binference.plotting.plot_population(result, ax=None, *, which='density', levels=(0.68, 0.95), truth=None, stack=None, color=None, sample_color=None, label=None, alpha=0.25, step=True)[source]¶
Plot a population posterior: bands for 1-D bins, images for 2-D grids, bars for categories.
Overlays (
truth,stack) contribute only their shape: for rates (and rate models) they are scaled to the posterior mean total. For the selected population the truth is reweighted by the fit’s selection, which a basis other than the bins must not have (it weighs components); the stack is not, as it averages the observed objects and so estimates the selected population already. 2-D grids show the median and the relative uncertainty as images and take no overlays.- Parameters:
- resultPopulationResult or PointEstimate
- axmatplotlib Axes, optional
Axes to draw on;
Nonemakes a new figure.- which{“density”, “fractions”, “rates”, “selected”}
Plot densities per unit volume (n(z)-style), fractions per bin, rates, or the selected population per bin (the singular spellings are accepted too).
- levelssequence of float
Central credible levels shown as nested bands.
- trutharray_like (K,), optional
True fractions to overlay.
- stackarray_like, optional
A naive stacked estimate to overlay, as
Likelihoods.stackreturns it: one weight per bin, or per component of aBasisfit, which the plot shares among the bins.- colormatplotlib colour, optional
Colour of the posterior, or for categories a list of colours, one per bar;
Nonetakes the style’s first colour.- sample_colormatplotlib colour, optional
Colour of the
stackoverlay;Nonetakes the style’s second colour.- labelstr, optional
Legend label of the median (default “posterior median”).
- alphafloat
Opacity of each credible band.
- stepbool
Draw 1-D bins as steps (True) or as lines through the bin centres.
- Returns:
- matplotlib Axes, or an array of Axes for 2-D grids