Skip to main content
Ctrl+K
arviz-plots dev documentation - Home
BASE
STATS
PLOTS

User guide

  • Overview
  • Introduction to batteries-included plots
  • Using PlotCollection objects
  • Create your own figure with PlotCollection

Reference

  • Example gallery
    • Posterior ECDFs
    • Posterior Histograms
    • Posterior KDEs
    • Forest plot
    • Forest plot with shading
    • Plot prior and posterior
    • Scatterplot one variable against all others
    • Scatterplot all variables against each other
    • Ridge plot
    • Posterior KDEs for two models
    • Posterior forest for two models
    • Ridge plot for multiple models
    • Rank plot
    • Trace plot
    • ESS evolution
    • ESS local
    • ESS quantile
    • ESS comparison
    • Monte Carlo standard error
    • Convergence diagnostics distribution
    • Autocorrelation Plot
    • Energy
    • Scatter plot of one variable against all other variables with divergences
    • Scatter plot of all variables against each other with divergences
    • Parallel coordinates plot
    • Predictive check with KDEs
    • Rootogram
    • PAV-adjusted calibration
    • PIT ECDF
    • Coverage ECDF
    • LOO-PIT ECDF
    • Test statistics
    • Posterior predictive forest and observations
    • Sensitivity posterior marginals
    • Sensitivity posterior quantities
    • Predictive model comparison
    • Bayes_factor
    • PIT-ECDF
    • Coverage ECDF
    • Rank and distribution plot
    • Trace and distribution plot
    • Forest plot with ESS
    • Custom diagnostic plots combination
    • Add Lines
    • Add Reference Bands
  • API reference
    • Batteries-included plots
      • arviz_plots.combine_plots
      • arviz_plots.plot_autocorr
      • arviz_plots.plot_bf
      • arviz_plots.plot_compare
      • arviz_plots.plot_convergence_dist
      • arviz_plots.plot_dist
      • arviz_plots.plot_ecdf_pit
      • arviz_plots.plot_energy
      • arviz_plots.plot_ess
      • arviz_plots.plot_ess_evolution
      • arviz_plots.plot_forest
      • arviz_plots.plot_loo_pit
      • arviz_plots.plot_mcse
      • arviz_plots.plot_pair
      • arviz_plots.plot_pair_focus
      • arviz_plots.plot_parallel
      • arviz_plots.plot_ppc_dist
      • arviz_plots.plot_ppc_pava
      • arviz_plots.plot_ppc_pit
      • arviz_plots.plot_ppc_rootogram
      • arviz_plots.plot_ppc_tstat
      • arviz_plots.plot_prior_posterior
      • arviz_plots.plot_psense_dist
      • arviz_plots.plot_psense_quantities
      • arviz_plots.plot_rank
      • arviz_plots.plot_rank_dist
      • arviz_plots.plot_ridge
      • arviz_plots.plot_trace
      • arviz_plots.plot_trace_dist
    • Helper plotting functions
      • arviz_plots.add_bands
      • arviz_plots.add_lines
      • arviz_plots.style.available
      • arviz_plots.style.get
      • arviz_plots.style.use
    • Managers for faceting and aesthetics mapping
      • arviz_plots.PlotCollection
      • arviz_plots.PlotCollection.grid
      • arviz_plots.PlotCollection.wrap
      • arviz_plots.PlotCollection.add_legend
      • arviz_plots.PlotCollection.map
      • arviz_plots.PlotCollection.aes
      • arviz_plots.PlotCollection.viz
      • arviz_plots.PlotCollection.aes_set
      • arviz_plots.PlotCollection.facet_dims
      • arviz_plots.PlotCollection.data
      • arviz_plots.PlotCollection.generate_aes_dt
      • arviz_plots.PlotCollection.get_aes_as_dataset
      • arviz_plots.PlotCollection.get_aes_kwargs
      • arviz_plots.PlotCollection.update_aes
      • arviz_plots.PlotCollection.update_aes_from_dataset
      • arviz_plots.PlotCollection.allocate_artist
      • arviz_plots.PlotCollection.get_viz
      • arviz_plots.PlotCollection.get_target
      • arviz_plots.PlotCollection.show
      • arviz_plots.PlotCollection.savefig
      • arviz_plots.PlotMatrix
      • arviz_plots.PlotMatrix.map
      • arviz_plots.PlotMatrix.map_triangle
      • arviz_plots.PlotMatrix.map_lower
      • arviz_plots.PlotMatrix.map_upper
      • arviz_plots.PlotMatrix.map_row
      • arviz_plots.PlotMatrix.map_col
      • arviz_plots.PlotMatrix.aes
      • arviz_plots.PlotMatrix.viz
      • arviz_plots.PlotMatrix.aes_set
      • arviz_plots.PlotMatrix.facet_dims
      • arviz_plots.PlotMatrix.data
    • Visual elements
      • arviz_plots.visuals.ci_line_y
      • arviz_plots.visuals.ecdf_line
      • arviz_plots.visuals.fill_between_y
      • arviz_plots.visuals.hline
      • arviz_plots.visuals.hist
      • arviz_plots.visuals.hspan
      • arviz_plots.visuals.line
      • arviz_plots.visuals.multiple_lines
      • arviz_plots.visuals.line_xy
      • arviz_plots.visuals.line_x
      • arviz_plots.visuals.scatter_xy
      • arviz_plots.visuals.scatter_x
      • arviz_plots.visuals.scatter_xy
      • arviz_plots.visuals.scatter_couple
      • arviz_plots.visuals.trace_rug
      • arviz_plots.visuals.vline
      • arviz_plots.visuals.vspan
      • arviz_plots.visuals.annotate_label
      • arviz_plots.visuals.annotate_xy
      • arviz_plots.visuals.labelled_title
      • arviz_plots.visuals.labelled_x
      • arviz_plots.visuals.labelled_y
      • arviz_plots.visuals.label_plot
      • arviz_plots.visuals.point_estimate_text
      • arviz_plots.visuals.remove_axis
      • arviz_plots.visuals.remove_ticks
      • arviz_plots.visuals.set_xticks
      • arviz_plots.visuals.ticklabel_props
      • arviz_plots.visuals.grid
    • Interface to plotting backends
      • Matplotlib
        • arviz_plots.backend.matplotlib.create_plotting_grid
        • arviz_plots.backend.matplotlib.show
        • arviz_plots.backend.matplotlib.line
        • arviz_plots.backend.matplotlib.multiple_lines
        • arviz_plots.backend.matplotlib.scatter
        • arviz_plots.backend.matplotlib.text
        • arviz_plots.backend.matplotlib.title
        • arviz_plots.backend.matplotlib.ylabel
        • arviz_plots.backend.matplotlib.xlabel
        • arviz_plots.backend.matplotlib.xticks
        • arviz_plots.backend.matplotlib.yticks
        • arviz_plots.backend.matplotlib.ticklabel_props
        • arviz_plots.backend.matplotlib.remove_ticks
        • arviz_plots.backend.matplotlib.remove_axis
        • arviz_plots.backend.matplotlib.legend
      • Bokeh
        • arviz_plots.backend.bokeh.create_plotting_grid
        • arviz_plots.backend.bokeh.show
        • arviz_plots.backend.bokeh.line
        • arviz_plots.backend.bokeh.multiple_lines
        • arviz_plots.backend.bokeh.scatter
        • arviz_plots.backend.bokeh.text
        • arviz_plots.backend.bokeh.title
        • arviz_plots.backend.bokeh.ylabel
        • arviz_plots.backend.bokeh.xlabel
        • arviz_plots.backend.bokeh.xticks
        • arviz_plots.backend.bokeh.yticks
        • arviz_plots.backend.bokeh.ticklabel_props
        • arviz_plots.backend.bokeh.remove_ticks
        • arviz_plots.backend.bokeh.remove_axis
        • arviz_plots.backend.bokeh.legend
      • Plotly
        • arviz_plots.backend.plotly.create_plotting_grid
        • arviz_plots.backend.plotly.show
        • arviz_plots.backend.plotly.line
        • arviz_plots.backend.plotly.multiple_lines
        • arviz_plots.backend.plotly.scatter
        • arviz_plots.backend.plotly.text
        • arviz_plots.backend.plotly.title
        • arviz_plots.backend.plotly.ylabel
        • arviz_plots.backend.plotly.xlabel
        • arviz_plots.backend.plotly.xticks
        • arviz_plots.backend.plotly.yticks
        • arviz_plots.backend.plotly.ticklabel_props
        • arviz_plots.backend.plotly.remove_ticks
        • arviz_plots.backend.plotly.remove_axis
        • arviz_plots.backend.plotly.legend
      • None (only processing, no plotting)
        • arviz_plots.backend.none.create_plotting_grid
        • arviz_plots.backend.none.show
        • arviz_plots.backend.none.line
        • arviz_plots.backend.none.multiple_lines
        • arviz_plots.backend.none.scatter
        • arviz_plots.backend.none.text
        • arviz_plots.backend.none.title
        • arviz_plots.backend.none.ylabel
        • arviz_plots.backend.none.xlabel
        • arviz_plots.backend.none.xticks
        • arviz_plots.backend.none.yticks
        • arviz_plots.backend.none.ticklabel_props
        • arviz_plots.backend.none.remove_ticks
        • arviz_plots.backend.none.remove_axis
        • arviz_plots.backend.none.legend
  • Glossary

Tutorials

  • ArviZ in Context

Contributing

  • Testing
  • Adding a batteries-included plot
  • Documentation

About

  • BlueSky
  • Mastodon
  • GitHub repository
  • .md

Example gallery

Contents

  • Distribution visualization
  • Posterior comparison
  • Inference diagnostics
  • Predictive checks
  • Prior and likelihood sensitivity checks
  • Model Comparison
  • Simulation Based Calibration
  • Mixed plots
  • Helper Functions

Example gallery#

See also

Introduction to batteries-included plots: A general overview of batteries-included plotting functions, their common use cases, and the underlying logic.

Distribution visualization#

Faceted ECDF plots for 1D marginals of the distribution

Posterior ECDFs

Posterior ECDFs

Faceted histogram plots for 1D marginals of the distribution. The point_estimate_text option is set to False to omit that visual from the plot.

Posterior Histograms

Posterior Histograms

KDE plot of the variable mu from the centered eight model. The sample_dims parameter is used to restrict the KDE computation along the draw dimension only.”

Posterior KDEs

Posterior KDEs

Default forest plot with marginal distribution summaries

Forest plot

Forest plot

Forest plot marginal summaries with row shading to enhance reading

Forest plot with shading

Forest plot with shading

Plot prior and posterior marginal distributions.

Plot prior and posterior

Plot prior and posterior

Plot one variable against other variables in the dataset.

Scatterplot one variable against all others

Scatterplot one variable against all others

Plot all variables against each other in the dataset.

Scatterplot all variables against each other

Scatterplot all variables against each other

Visual representation of marginal distributions over the y axis for a single model

Ridge plot

Ridge plot

Posterior comparison#

Full marginal distribution comparison between different models

Posterior KDEs for two models

Posterior KDEs for two models

Forest plot summaries for 1D marginal distributions

Posterior forest for two models

Posterior forest for two models

Visual representation of marginal distributions over the y axis showing for multiple models

Ridge plot for multiple models

Ridge plot for multiple models

Inference diagnostics#

faceted plot with fractional ranks for each variable

Rank plot

Rank plot

faceted plot with MCMC traces for each variable

Trace plot

Trace plot

faceted plot with ESS ‘bulk’ and ‘tail’ for each variable

ESS evolution

ESS evolution

faceted local ESS plot

ESS local

ESS local

faceted quantile ESS plot

ESS quantile

ESS quantile

Full ESS (Either local or quantile) comparison between different models

ESS comparison

ESS comparison

faceted quantile MCSE plot

Monte Carlo standard error

Monte Carlo standard error

Plot the distribution of ESS and R-hat.

Convergence diagnostics distribution

Convergence diagnostics distribution

faceted plot with autocorrelation for each variable

Autocorrelation Plot

Autocorrelation Plot

Plot transition and marginal energy distributions

Energy

Energy

Plot one variable against other variables in the dataset.

Scatter plot of one variable against all other variables with divergences

Scatter plot of one variable against all other variables with divergences

Plot all variables against each other in the dataset.

Scatter plot of all variables against each other with divergences

Scatter plot of all variables against each other with divergences

Plot parallel coordinates plot showing posterior points with divergences..

Parallel coordinates plot

Parallel coordinates plot

Predictive checks#

Plot of samples from the posterior predictive and observed data.

Predictive check with KDEs

Predictive check with KDEs

Rootogram for the posterior predictive and observed data.

Rootogram

Rootogram

PAV-adjusted calibration plot for binary predictions.

PAV-adjusted calibration

PAV-adjusted calibration

Plot of the probability integral transform of the posterior predictive distribution with respect to the observed data.

PIT ECDF

PIT ECDF

Proportion of true values that fall within a given prediction interval.

Coverage ECDF

Coverage ECDF

Plot of the probability integral transform of the posterior predictive distribution with respect to the observed data using the leave-one-out (LOO) method.

LOO-PIT ECDF

LOO-PIT ECDF

T-statistic for the observed data and posterior predictive data.

Test statistics

Test statistics

Overlay of forest plot for the posterior predictive samples and the actual observations

Posterior predictive forest and observations

Posterior predictive forest and observations

Prior and likelihood sensitivity checks#

The posterior sensitivity is assessed by power-scaling the prior or likelihood and visualizing the resulting changes. Sensitivity can then be quantified by considering how much the perturbed posteriors differ from the base posterior.

Sensitivity posterior marginals

Sensitivity posterior marginals

The posterior quantities are computed by power-scaling the prior or likelihood and visualizing the resulting changes. Sensitivity can then be quantified by considering how much the perturbed quantities differ from the base quantities.

Sensitivity posterior quantities

Sensitivity posterior quantities

Model Comparison#

Compare multiple models using predictive accuracy estimated using PSIS-LOO-CV. Usually the DataFrame cmp_df is generated using ArviZ’s ```compare` function.

Predictive model comparison

Predictive model comparison

Compute Bayes factor using Savage–Dickey ratio. We can apply this function when the null model is nested within the alternative. In other words when the null (ref_val) is a particular value of the model we are building (see here). For others cases computing Bayes factor is not straightforward and requires more complex methods. Instead, of Bayes factors, we usually recommend Pareto smoothed importance sampling leave one out cross validation (PSIS-LOO-CV). In ArviZ, you will find them as functions with loo in their names.

Bayes_factor

Bayes_factor

Simulation Based Calibration#

Faceted plot with PIT Δ-ECDF values for each variable The plot_ecdf_pit function assumes the values passed to it has already been transformed to PIT values, as in the case of SBC analysis or values from arviz_base.loo_pit. The distribution should be uniform if the model is well-calibrated. To make the plot easier to interpret, we plot the Δ-ECDF, that is, the difference between the expected CDF from the observed ECDF. As small deviations from uniformity are expected, the plot also shows the credible envelope.

PIT-ECDF

PIT-ECDF

Coverage refers to the proportion of true values that fall within a given prediction interval. For a well-calibrated model, the coverage should match the intended interval width. For example, a 95% credible interval should contain the true value 95% of the time. The distribution should be uniform if the model is well-calibrated. To make the plot easier to interpret, we plot the Δ-ECDF, that is, the difference between the expected CDF from the observed ECDF. As small deviations from uniformity are expected, the plot also shows the credible envelope. We can compute the coverage for equal-tailed intervals (ETI) by passing coverage=True to the plot_ecdf_pit function. This works because ETI coverage can be obtained by transforming the PIT values. However, for other interval types, such as HDI, coverage must be computed explicitly and is not supported by this function.

Coverage ECDF

Coverage ECDF

Mixed plots#

Two column layout with marginal distributions on the left and fractional ranks on the right

Rank and distribution plot

Rank and distribution plot

Two column layout with marginal distributions on the left and MCMC traces on the right

Trace and distribution plot

Trace and distribution plot

Multiple panel visualization with a forest plot and ESS information

Forest plot with ESS

Forest plot with ESS

Arrange three diagnostic plots (ESS evolution plot, rank plot and autocorrelation plot) in a custom column layout.

Custom diagnostic plots combination

Custom diagnostic plots combination

Helper Functions#

Draw lines on plots to highlight specific thresholds, targets, or important values.

Add Lines

Add Lines

Draw reference bands to highlight specific regions.

Add Reference Bands

Add Reference Bands

previous

Create your own figure with PlotCollection

next

Posterior ECDFs

Contents
  • Distribution visualization
  • Posterior comparison
  • Inference diagnostics
  • Predictive checks
  • Prior and likelihood sensitivity checks
  • Model Comparison
  • Simulation Based Calibration
  • Mixed plots
  • Helper Functions

By ArviZ team

© Copyright 2022, ArviZ team.