arviz.plot_autocorr(data, var_names=None, max_lag=None, combined=False, figsize=None, textsize=None, ax=None)[source]

Bar plot of the autocorrelation function for a sequence of data.

Useful in particular for posteriors from MCMC samples which may display correlation.


Any object that can be converted to an az.InferenceData object Refer to documentation of az.convert_to_dataset for details

var_nameslist of variable names, optional

Variables to be plotted, if None all variable are plotted. Vector-value stochastics are handled automatically.

max_lagint, optional

Maximum lag to calculate autocorrelation. Defaults to 100 or num draws, whichever is smaller


Flag for combining multiple chains into a single chain. If False (default), chains will be plotted separately.


Figure size. If None it will be defined automatically. Note this is not used if ax is supplied.

textsize: float

Text size scaling factor for labels, titles and lines. If None it will be autoscaled based on figsize.

ax: axes

Matplotlib axes

axesmatplotlib axes


Plot default autocorrelation

>>> import arviz as az
>>> data = az.load_arviz_data('centered_eight')
>>> az.plot_autocorr(data)

Plot subset variables by specifying variable name exactly

>>> az.plot_autocorr(data, var_names=['mu', 'tau'] )

Combine chains collapsing by variable

>>> az.plot_autocorr(data, var_names=['mu', 'tau'], combined=True)

Specify maximum lag (x axis bound)

>>> az.plot_autocorr(data, var_names=['mu', 'tau'], max_lag=200, combined=True)