asterion.plotting#

The plotting module contains functions for plotting inference data.

Module Contents#

get_labeller(data, group='posterior', var_names=None)[source]#

Get labeller for use with arviz plotting. This automatically searches variable metadata (contained in their attrs dictionary) for its ‘symbol’ and ‘unit’ if available.

Parameters
  • data (arviz.InferenceData) – Inference data object.

  • group (str) – Inference data group for which to map labels.

  • var_names (list[str], optional) – Variable names for which to map labels.

Returns

Label map.

Return type

arviz.labels.MapLabeller

plot_corner(data, group='posterior', var_names=None, quantiles=None, labeller='auto', **kwargs)[source]#

A wrapper for corner.corner() with automatic labelling and custom default arguments specified below.

Parameters
  • data (arviz.InferenceData) – Inference data object.

  • group (str) – Inference data group from which to take samples. Defaults to ‘posterior’.

  • var_names (List[str], optional) – Variable names to plot. Defaults to plotting all available variables.

  • quantiles (iterable, optional) – Quantiles to plot as dashed lines in the marginals. If None, defaults to the 68% confidence interval. Pass an empty list to plot no confidence intervals.

  • labeller (str, or MapLabeller) – Labeller which maps variable names to their axis labels. Defaults to ‘auto’.

  • **kwargs – Keyword arguments to pass to corner.corner().

Returns

Figure object.

Return type

matplotlib.figure.Figure

See also

corner.corner(): The function for which this wraps.

plot_glitch(data, group='posterior', kind='full', x_var='n', quantiles=None, observed='auto', use_alpha=True, ax=None, **kwargs)[source]#

Plot the glitch from either the prior or posterior predictive contained in inference data.

Parameters
  • data (arviz.InferenceData) – Inference data object.

  • group (str) – One of [‘posterior’, ‘prior’].

  • kind (str) – Kind of glitch to plot. One of [‘full’, ‘helium’, ‘BCZ’].

  • x_var (str) – Variable name for x-axis. One of [‘n’, ‘nu’]. If ‘nu’, the median value of ‘nu’ in data['group'] is used.

  • quantiles (iterable, optional) – Quantiles to plot as confidence intervals. If None, defaults to the 68% confidence interval. Pass an empty list to plot no confidence intervals.

  • observed (bool or str) – Whether to plot observed data. Default is “auto” which will plot observed data when group is “posterior”.

  • use_alpha (bool) – Whether to use alpha channel for transparency. If False, will shade with lightened solid color.

  • ax (matplotlib.axes.Axes) – Axis on which to plot the glitch.

  • **kwargs – Keyword arguments to pass to matplotlib.pyplot.plot().

Raises

ValueError – If kind is not valid.

Returns

Axis on which the glitch is plot.

Return type

matplotlib.axes.Axes