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
dataobj

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

Variables to be plotted, if None all variable are plotted

coordsmapping, optional

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

figsizefigure 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.

kindstr

Type of plot to display (kde or hexbin)

gridsizeint 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.

contourbool

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

fill_lastbool

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

divergencesBoolean

If True divergences will be plotted in a different color

colorbarbool

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_kwargsdicts, optional

Additional keywords passed to ax.scatter for divergences

plot_kwargsdicts, optional

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

Returns
——-
axmatplotlib 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