arviz.plot_dist_comparison#
- arviz.plot_dist_comparison(data, kind='latent', figsize=None, textsize=None, var_names=None, coords=None, combine_dims=None, transform=None, legend=True, labeller=None, ax=None, prior_kwargs=None, posterior_kwargs=None, observed_kwargs=None, backend=None, backend_kwargs=None, show=None)[source]#
Plot to compare fitted and unfitted distributions.
The resulting plots will show the compared distributions both on separate axes (particularly useful when one of them is substantially tighter than another), and plotted together, displaying a grid of three plots per distribution.
- Parameters:
- data
InferenceData
Any object that can be converted to an
arviz.InferenceData
object containing the posterior/prior data. Refer to documentation ofarviz.convert_to_dataset()
for details.- kind{“latent”, “observed”}, default “latent”
kind of plot to display The “latent” option includes {“prior”, “posterior”}, and the “observed” option includes {“observed_data”, “prior_predictive”, “posterior_predictive”}.
- figsize(
float
,float
), optional Figure size. If
None
it will be defined automatically.- textsize
float
Text size scaling factor for labels, titles and lines. If
None
it will be autoscaled based onfigsize
.- var_names
str
,list
,list
oflists
, optional if str, plot the variable. if list, plot all the variables in list of all groups. if list of lists, plot the vars of groups in respective lists. See this section for usage examples.
- coords
dict
Dictionary mapping dimensions to selected coordinates to be plotted. Dimensions without a mapping specified will include all coordinates for that dimension. See this section for usage examples.
- combine_dims
set_like
ofstr
, optional List of dimensions to reduce. Defaults to reducing only the “chain” and “draw” dimensions. See this section for usage examples.
- transform
callable()
Function to transform data (defaults to
None
i.e. the identity function).- legendbool
Add legend to figure. By default True.
- labellerLabeller, optional
Class providing the method
make_pp_label
to generate the labels in the plot titles. Read the Label guide for more details and usage examples.- ax(
nvars
, 3) array_like ofmatplotlib Axes
, optional Matplotlib axes: The ax argument should have shape (nvars, 3), where the last column is for the combined before/after plots and columns 0 and 1 are for the before and after plots, respectively.
- prior_kwargs
dicts
, optional Additional keywords passed to
arviz.plot_dist()
for prior/predictive groups.- posterior_kwargs
dicts
, optional Additional keywords passed to
arviz.plot_dist()
for posterior/predictive groups.- observed_kwargs
dicts
, optional Additional keywords passed to
arviz.plot_dist()
for observed_data group.- backend{“matplotlib”, “bokeh”}, default “matplotlib”
Select plotting backend.
- backend_kwargs
dict
, optional These are kwargs specific to the backend being used, passed to
matplotlib.pyplot.subplots()
orbokeh.plotting.figure
. For additional documentation check the plotting method of the backend.- showbool, optional
Call backend show function.
- data
- Returns:
- axes2D
ndarray
ofmatplotlib Axes
Returned object will have shape (nvars, 3), where the last column is the combined plot and the first columns are the single plots.
- axes2D
See also
plot_bpv
Plot Bayesian p-value for observed data and Posterior/Prior predictive.
Examples
Plot the prior/posterior plot for specified vars and coords.
>>> import arviz as az >>> data = az.load_arviz_data('rugby') >>> az.plot_dist_comparison(data, var_names=["defs"], coords={"team" : ["Italy"]})