arviz.plot_pair

arviz.plot_pair(data, var_names=None, coords=None, figsize=None, textsize=None, kind='scatter', gridsize='auto', contour=True, fill_last=True, divergences=False, colorbar=False, ax=None, divergences_kwargs=None, plot_kwargs=None)[source]

Plot a scatter or hexbin matrix of the sampled parameters.

Parameters:
data : obj

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

var_names : list of variable names

Variables to be plotted, if None all variable are plotted

coords : mapping, optional

Coordinates of var_names to be plotted. Passed to Dataset.sel

figsize : figure size tuple

If None, size is (8 + numvars, 8 + numvars)

textsize: int

Text size for labels. If None it will be autoscaled based on figsize.

kind : str

Type of plot to display (kde or hexbin)

gridsize : int or (int, int), optional

Only works for kind=hexbin. The number of hexagons in the x-direction. The corresponding number of hexagons in the y-direction is chosen such that the hexagons are approximately regular. Alternatively, gridsize can be a tuple with two elements specifying the number of hexagons in the x-direction and the y-direction.

contour : bool

If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE. Defaults to True.

fill_last : bool

If True fill the last contour of the 2D KDE plot. Defaults to True.

divergences : Boolean

If True divergences will be plotted in a different color

colorbar : bool

If True a colorbar will be included as part of the plot (Defaults to False). Only works when kind=hexbin

ax: axes

Matplotlib axes

divergences_kwargs : dicts, optional

Additional keywords passed to ax.scatter for divergences

plot_kwargs : dicts, optional

Additional keywords passed to ax.plot, az.plot_kde or ax.hexbin

Returns
——-
ax : matplotlib axes

Examples

KDE Pair Plot

>>> import arviz as az
>>> centered = az.load_arviz_data('centered_eight')
>>> coords = {'school': ['Choate', 'Deerfield']}
>>> az.plot_pair(centered,
>>>             var_names=['theta', 'mu', 'tau'],
>>>             kind='kde',
>>>             coords=coords,
>>>             divergences=True,
>>>             textsize=18)
../_images/arviz-plot_pair-1.png

Hexbin pair plot

>>> az.plot_pair(centered,
>>>             var_names=['theta', 'mu'],
>>>             coords=coords,
>>>             textsize=18,
>>>             kind='hexbin')
../_images/arviz-plot_pair-2.png

Pair plot showing divergences

>>> az.plot_pair(centered,
...             var_names=['theta', 'mu', 'tau'],
...             coords=coords,
...             divergences=True,
...             textsize=18)
../_images/arviz-plot_pair-3.png