plot_density()

Contents

plot_density()#

liesel.goose.plot_density(results, params=None, param_indices=None, chain_indices=None, max_chains=5, title=None, title_spacing=0.85, xlabel='Value', style='whitegrid', color_palette=None, ncol=3, height=3, aspect_ratio=1, save_path=None, **kwargs)[source]#

Visualizes posterior distributions with a density plot.

Parameters:
  • results (SamplingResults) – Result object of the sampling process. Must have a method get_posterior_samples() which extracts all samples from the posterior distribution.

  • params (Union[str, list[str], None]) – Names of the model parameters that are contained in the plot. Must coincide with the dictionary keys of the Position with the posterior samples. If None, all parameters are included. (default: None)

  • param_indices (Union[int, Sequence[int], None]) – Indices of each model parameter that are contained in the plot. Selects e.g. beta[0] out of a beta parameter vector. A single index can be specified as an integer or a sequence containing one integer. If None, all subparameters are included. (default: None)

  • chain_indices (Union[int, Sequence[int], None]) – Indices of chains for each model subparameter that are contained in the plot. Selects e.g. chain 0 and chain 2 out of multiple chains. A single index can be specified as an integer or a sequence containing one integer. If None, all chains are included. (default: None)

  • max_chains (int | None) – Upper bound how many chains are included within each subplot/facet. Avoids overplotting. If None, all chains contained in the results input are plotted. Always starts chain selection from the lowest chain index upwards. For selecting specific chains use the argument chain_indices. (default: 5)

  • title (Optional[str]) – Plot title. (default: None)

  • title_spacing (float) – Determines the margin/whitespace between the plot title (set with fig.suptitle()) and the first row of subplots/facets. Passed to the top argument of fig.subplots_adjust(). (default: 0.85)

  • xlabel (str) – Label of the x-axis. (default: 'Value')

  • style (str) – Passed to the style argument of sns.set_theme(). Valid options are darkgrid, whitegrid, dark, white, and ticks. (default: 'whitegrid')

  • color_palette (Union[str, list[str], dict[int, str], None]) – Passed to the palette argument of sns.displot(). String values must be valid inputs of sns.color_palette() such as a seaborn color palette or a matplotlib colormap. Custom colors can be set with a list of color strings or a dictionary with the chain indices as keys and color strings as values. The number of color strings must coincide with the number of plotted chains. If None, the default tab10 matplotlib colormap is chosen. (default: None)

  • ncol (int) – Number of subplots/facets within each row of the grid. (default: 3)

  • height (int) – Height in inches of each subplot/facet within the grid. (default: 3)

  • aspect_ratio (int) – Ratio of width / height of each subplot/facet within the grid, i.e. width = aspect_ratio * height. (default: 1)

  • save_path (Optional[str]) – File path where the plot is saved. (default: None)

  • **kwargs – Further keyword arguments passed to the seaborn displot() function.

Return type:

FacetGrid

Returns:

A seaborn FacetGrid.