nessai.plot

Plotting utilities.

Module Contents

Functions

nessai_style([line_styles])

Decorator for plotting function that sets the style.

plot_live_points(live_points[, filename, bounds, c])

Plot a set of live points in a corner-like plot.

plot_1d_comparison(*live_points[, parameters, labels, ...])

Plot 1d histograms comparing different sets of live points

plot_indices(indices[, nlive, filename, plot_breakdown])

Histogram indices for index insertion tests, also includes the CDF.

plot_loss(epoch, history[, filename])

Plot the loss function per epoch.

plot_trace(log_x, nested_samples[, parameters, ...])

Produce trace plot for the nested samples.

plot_histogram(samples[, label, filename])

Plot a histogram of samples.

corner_plot(array[, include, exclude, labels, truths, ...])

Produce a corner plot for a structured array.

nessai.plot.nessai_style(line_styles=True)

Decorator for plotting function that sets the style.

Functions as both standard decorator @nessai_style or as a callable decorator @nessai_style().

Style can be disabled by setting nessai.config.DISABLE_STYLE to True.

Parameters:
line_stylesboolean

Use custom line styles.

nessai.plot.plot_live_points(live_points, filename=None, bounds=None, c=None, **kwargs)

Plot a set of live points in a corner-like plot.

Will drop columns where all elements are NaNs

Parameters:
live_pointsndarray

Structured array of live points to plot.

filenamestr

Filename for resulting figure

boundsdict:

Dictionary of lower and upper bounds to plot

cstr, optional

Name of field in the structured array to use as the hue when plotting the samples. If not specified, no hue is used.

kwargs

Keyword arguments used to update the pairplot kwargs. Diagonal and off- diagonal plots can be configured with diag_kws and plot_kws.

nessai.plot.plot_1d_comparison(*live_points, parameters=None, labels=None, colours=None, bounds=None, hist_kwargs={}, filename=None, convert_to_live_points=False)

Plot 1d histograms comparing different sets of live points

Parameters:
*live_pointsiterable of ndarrays

Variable length argument of live points in structured arrays with fields. Also see parameters argument.

parametersarray_like, optional

Array of parameters (field names) to plot. Default None implies all fields are plotted.

labelslist, optional

List of labels for each structured array being plotted (default None). If None each set of live points is labelled numerically

colourslist, optional

List of colours to use for each set of live points.

boundsdict, optional

Dictionary of upper and lowers bounds to plot. Each key must match a field and each value must be an interable of length 2 in order lower then upper bound. If None (default), no bounds plotted.

hist_kwargsdict, optional

Dictionary of keyword arguments passed to matplotlib.pyplot.hist.

filenamestr, optional

Name of file for saving figure. (Default None implies figure is not saved).

convert_to_live_pointsbool, optional

Set to true if inputs are not structured arrays of live points

nessai.plot.plot_indices(indices, nlive=None, filename=None, plot_breakdown=True)

Histogram indices for index insertion tests, also includes the CDF.

Parameters:
indicesarray_like

List of insertion indices to plot

nliveint

Number of live points used in the nested sampling run

filenamestr

Filename used to save the figure.

plot_breakdownbool, optional

If true, then the CDF for every nlive points is also plotted as grey lines.

nessai.plot.plot_loss(epoch, history, filename=None)

Plot the loss function per epoch.

Parameters:
epochint

Final training epoch

historydict

Dictionary with keys 'loss' and 'val_loss'

filenamestr, optional

Path for saving the figure. If not specified figure is returned instead.

nessai.plot.plot_trace(log_x: numpy.ndarray, nested_samples: numpy.ndarray, parameters: List[str] | None = None, live_points: numpy.ndarray | None = None, log_x_live_points: numpy.ndarray | None = None, labels: List[str] | None = None, filename: str | None = None, **kwargs)

Produce trace plot for the nested samples.

By default this includes all parameters in the samples, not just those included in the model being sampled.

Parameters:
log_xarray_like

Array of log prior volumes

nested_samplesndarray

Array of nested samples to plot

parameterslist, optional

List of parameters to include the trace plot. If not specified, all of the parameters in the nested samples are included.

live_pointsndarray

Optional array of live points to include in the plot. See also log_x_live_points.

log_x_live_pointsndarray

Optional array of log-prior volumes for the live points. Required if live_points is specified.

labelslist, optional

List of labels to use instead of the names of parameters

filenamestr, optional

Filename for saving the plot, if none plot is not saved and figure is returned instead.

kwargs

Keyword arguments passed to matplotlib.pyplot.plot.

nessai.plot.plot_histogram(samples, label=None, filename=None, **kwargs)

Plot a histogram of samples.

Parameters:
samplesarray_like

Samples to plot.

labelstr, optional

Label to the x axis.

filenamestr, optional

Filename for saving the plot. If not specified, figure is returned.

kwargs

Keyword arguments passed to matplotlib.pyplot.hist.

nessai.plot.corner_plot(array, include=None, exclude=None, labels=None, truths=None, filename=None, **kwargs)

Produce a corner plot for a structured array.

Removes any fields with no dynamic range.

Parameters:
arraynumpy.ndarray

Structured array

includeOptional[list]

List of parameters to plot.

excludeOptional[list]

List of parameters to exclude.

labelsOptional[Iterable]

Labels for each parameter that is to be plotted.

truthsOptional[Union[Iterable, Dict]]

Truth values for each parameters, parameters can be skipped by setting the value to None.

filenameOptional[str]

Filename for saving the plot. If not specified, figure is returned.

kwargsDict[Any]

Dictionary of keyword arguments passed to corner.corner.