nessai.plot
===========

.. py:module:: nessai.plot

.. autoapi-nested-parse::

   Plotting utilities.

   ..
       !! processed by numpydoc !!


Functions
---------

.. autoapisummary::

   nessai.plot.nessai_style
   nessai.plot.sanitise_array
   nessai.plot.plot_live_points
   nessai.plot.plot_1d_comparison
   nessai.plot.plot_indices
   nessai.plot.plot_loss
   nessai.plot.plot_trace
   nessai.plot.plot_histogram
   nessai.plot.corner_plot


Module Contents
---------------

.. py:function:: nessai_style(line_styles=True)

   
   Decorator for plotting function that sets the style.

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

   Style can be disabled by setting :py:data:`nessai.config.DISABLE_STYLE` to
   :code:`True`.

   :Parameters:

       **line_styles** : boolean
           Use custom line styles.














   ..
       !! processed by numpydoc !!

.. py:function:: sanitise_array(a: numpy.ndarray, /, a_min: Optional[float] = None, a_max: Optional[float] = None)

   
   Sanitise an array for plotting.

   If :code:`x_min` is not specified, it is set to the value in
   :code:`nessai.config.plotting.clip_min`.

   :Parameters:

       **x** : array_like
           Array to sanitise.

       **x_min** : float, optional
           Minimum value to clip the data to.

       **xmax** : float, optional
           Maximum value to clip the data to.



   :Returns:

       np.ndarray
           Sanitised array.











   ..
       !! processed by numpydoc !!

.. py:function:: 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_points** : ndarray
           Structured array of live points to plot.

       **filename** : str
           Filename for resulting figure

       **bounds** : dict:
           Dictionary of lower and upper bounds to plot

       **c** : str, 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``.














   ..
       !! processed by numpydoc !!

.. py:function:: 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_points** : iterable of ndarrays
           Variable length argument of live points in structured arrays with
           fields. Also see ``parameters`` argument.

       **parameters** : array_like, optional
           Array of parameters (field names) to plot. Default None implies all
           fields are plotted.

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

       **colours** : list, optional
           List of colours to use for each set of live points.

       **bounds** : dict, 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_kwargs** : dict, optional
           Dictionary of keyword arguments passed to matplotlib.pyplot.hist.

       **filename** : str, optional
           Name of file for saving figure. (Default None implies figure is not
           saved).

       **convert_to_live_points** : bool, optional
           Set to true if inputs are not structured arrays of live points














   ..
       !! processed by numpydoc !!

.. py:function:: plot_indices(indices, nlive=None, filename=None, ks_test_mode='D+', confidence_intervals=(0.68, 0.95, 0.997), plot_breakdown=True, n_breakdown=8, cmap='viridis')

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


   :Parameters:

       **indices** : array_like
           List of insertion indices to plot

       **nlive** : int
           Number of live points used in the nested sampling run. If nlive is not
           specified, it is set to the maximum value in indices.

       **filename** : str
           Filename used to save the figure.

       **plot_breakdown** : bool, optional
           If true, then the CDF for every nlive points is also plotted as grey
           lines.

       **ks_test_mode** : Literal["D+", "D-"]
           Mode for computing the KS test. See
           :py:func:`nessai.utils.indices.compute_indices_ks_test` for details.

       **confidence_intervals** : tuple
           Confidence intervals to plot as shaded regions on the cmf plot.

       **plot_breakdown** : bool
           If true, plots the cmf for batches of samples over the course of the
           run. The number of batches in controlled by :code:`n_breakdown`.

       **n_breakdown** : int
           The number of batches to plot. Also see :code:`plot_breakdown`.

       **cmap** : str
           Colourmap to use when :code:`plot_breakdown=True`.














   ..
       !! processed by numpydoc !!

.. py:function:: plot_loss(epoch, history, filename=None)

   
   Plot the loss function per epoch.


   :Parameters:

       **epoch** : int
           Final training epoch

       **history** : dict
           Dictionary with keys ``'loss'`` and ``'val_loss'``

       **filename** : str, optional
           Path for saving the figure. If not specified figure is returned
           instead.














   ..
       !! processed by numpydoc !!

.. py:function:: plot_trace(log_x: numpy.ndarray, nested_samples: numpy.ndarray, parameters: Optional[List[str]] = None, live_points: Optional[numpy.ndarray] = None, log_x_live_points: Optional[numpy.ndarray] = None, labels: Optional[List[str]] = None, filename: Optional[str] = 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_x** : array_like
           Array of log prior volumes

       **nested_samples** : ndarray
           Array of nested samples to plot

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

       **live_points** : ndarray
           Optional array of live points to include in the plot. See also
           :code:`log_x_live_points`.

       **log_x_live_points** : ndarray
           Optional array of log-prior volumes for the live points. Required if
           :code:`live_points` is specified.

       **labels** : list, optional
           List of labels to use instead of the names of parameters

       **filename** : str, optional
           Filename for saving the plot, if none plot is not saved and figure
           is returned instead.

       **kwargs**
           Keyword arguments passed to :code:`matplotlib.pyplot.plot`.














   ..
       !! processed by numpydoc !!

.. py:function:: plot_histogram(samples, label=None, filename=None, **kwargs)

   
   Plot a histogram of samples.


   :Parameters:

       **samples** : array_like
           Samples to plot.

       **label** : str, optional
           Label to the x axis.

       **filename** : str, optional
           Filename for saving the plot. If not specified, figure is returned.

       **kwargs**
           Keyword arguments passed to `matplotlib.pyplot.hist`.














   ..
       !! processed by numpydoc !!

.. py:function:: 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:

       **array** : numpy.ndarray
           Structured array

       **include** : Optional[list]
           List of parameters to plot.

       **exclude** : Optional[list]
           List of parameters to exclude.

       **labels** : Optional[Iterable]
           Labels for each parameter that is to be plotted.

       **truths** : Optional[Union[Iterable, Dict]]
           Truth values for each parameters, parameters can be skipped by setting
           the value to None.

       **filename** : Optional[str]
           Filename for saving the plot. If not specified, figure is returned.

       **kwargs** : Dict[Any]
           Dictionary of keyword arguments passed to :code:`corner.corner`.














   ..
       !! processed by numpydoc !!

