gensbi.utils.plotting#

Attributes#

Functions#

_parse_range(range_arg, ndim)

_plot_marginals_2d(data[, plot_levels, labels, ...])

_plot_marginals_corner(data[, labels, gridsize, ...])

_plot_marginals_nd(data[, plot_levels, labels, ...])

plot_2d_dist_contour(x, y, Z[, true_param, levels, cmap])

Plot a 2D contour plot of a distribution.

plot_2d_levels(x, y, Z, ax[, levels])

Plot 2D levels on a given axis.

plot_marginals(data[, backend, plot_levels, labels, ...])

Plot marginal distributions of multidimensional data using either the 'corner' or 'seaborn' backend.

plot_trajectories(traj)

Module Contents#

gensbi.utils.plotting._parse_range(range_arg, ndim)[source]#
gensbi.utils.plotting._plot_marginals_2d(data, plot_levels=True, labels=None, gridsize=15, hexbin_kwargs={}, histplot_kwargs={}, range=None, true_param=None, **kwargs)[source]#
gensbi.utils.plotting._plot_marginals_corner(data, labels=None, gridsize=25, range=None, true_param=None, **kwargs)[source]#
gensbi.utils.plotting._plot_marginals_nd(data, plot_levels=True, labels=None, gridsize=15, range=None, hexbin_kwargs={}, histplot_kwargs={}, true_param=None)[source]#
gensbi.utils.plotting.plot_2d_dist_contour(x, y, Z, true_param=None, levels=[0.6827, 0.9545], cmap=cmap_lcontour)[source]#

Plot a 2D contour plot of a distribution.

Parameters:
  • x (array-like) – X values.

  • y (array-like) – Y values.

  • Z (array-like) – Z values corresponding to (x, y).

  • levels (list or None, optional) – Contour levels to plot. If None, contours will not be plotted.

Returns:

fig, ax – The figure and axes containing the plot.

Return type:

matplotlib Figure and Axes objects

gensbi.utils.plotting.plot_2d_levels(x, y, Z, ax, levels=[0.6827, 0.9545])[source]#

Plot 2D levels on a given axis.

Parameters:
  • x (array-like) – X values.

  • y (array-like) – Y values.

  • Z (array-like) – Z values corresponding to (x, y).

  • ax (matplotlib Axes) – The axes to plot on.

  • levels (list of float) – The contour levels to plot.

gensbi.utils.plotting.plot_marginals(data, backend='corner', plot_levels=True, labels=None, gridsize=15, hexbin_kwargs={}, histplot_kwargs={}, range=None, true_param=None, **kwargs)[source]#

Plot marginal distributions of multidimensional data using either the ‘corner’ or ‘seaborn’ backend.

Parameters:
  • data (array-like, shape (n_samples, n_dim)) – The data to plot. Each row is a sample, each column a parameter.

  • backend (str, default="corner") – Which plotting backend to use. Options: - ‘corner’: Use the corner.py package for a classic corner plot. - ‘seaborn’: Use seaborn’s jointplot (2D) or custom grid (ND) for marginals. The seaborn backend is slower, but will produce smoother plots with KDE contours.

  • plot_levels (bool, default=True) – If True and using seaborn, plot 1- and 2-sigma KDE contours on off-diagonal plots. When using ‘corner’, levels are automatically computed.

  • labels (list of str or None, default=None) – Axis labels for each parameter. If None, uses LaTeX-style $ heta_i$.

  • gridsize (int, default=15) – Number of bins for hexbin/histogram (seaborn) or for corner plot.

  • hexbin_kwargs (dict, default={}) – Additional keyword arguments for hexbin plots (seaborn backend only).

  • histplot_kwargs (dict, default={}) – Additional keyword arguments for histogram plots (seaborn backend only).

  • range (tuple or list of tuples or None, default=None) – Axis limits for each parameter, e.g. [(xmin, xmax), (ymin, ymax), …].

  • true_param (array-like, shape (n_dim,), default=None) – Ground truth parameter values to mark on the plots.

  • **kwargs – Additional keyword arguments passed to the underlying plotting functions.

Returns:

fig, axes – The figure and axes containing the plot.

Return type:

matplotlib Figure and Axes objects

Raises:

ValueError – If an unknown backend is specified.

Notes

  • For ‘corner’, the function uses the corner.py package and supports labels, gridsize, range, and true_param.

  • For ‘seaborn’, 2D data uses jointplot, higher dimensions use a custom grid of hexbin and histogram plots.

gensbi.utils.plotting.plot_trajectories(traj)[source]#
gensbi.utils.plotting.base_color = '#CD5656'[source]#
gensbi.utils.plotting.cmap_lcontour[source]#
gensbi.utils.plotting.colors[source]#
gensbi.utils.plotting.hist_color = '#202A44'[source]#
gensbi.utils.plotting.rgb_base[source]#
gensbi.utils.plotting.transparent_cmap[source]#
gensbi.utils.plotting.true_val_color = '#687FE5'[source]#