arviz_plots.plot_pair

Contents

arviz_plots.plot_pair#

arviz_plots.plot_pair(dt, var_names=None, filter_vars=None, group='posterior', coords=None, sample_dims=None, marginal=True, marginal_kind=None, triangle='lower', plot_matrix=None, backend=None, labeller=None, aes_by_visuals=None, visuals=None, stats=None, **pc_kwargs)[source]#

Plot all variables against each other in the dataset.

Parameters:
dtxarray.DataTree

Input data

var_names: str or list of str, optional

One or more variables to be plotted. Prefix the variables by ~ when you want to exclude them from the plot.

filter_vars: {None, “like”, “regex”}, default None

If None (default), interpret var_names as the real variables names. If “like”, interpret var_names as substrings of the real variables names. If “regex”, interpret var_names as regular expressions on the real variables names.

groupstr, default “posterior”

Group to use for plotting. Defaults to “posterior”.

coordsmapping, optional

Coordinates to use for plotting.

sample_dimsiterable, optional

Dimensions to reduce unless mapped to an aesthetic. Defaults to rcParams["data.sample_dims"]

marginalbool, default True

Whether to plot marginal distributions on the diagonal.

marginal_kind{“kde”, “hist”, “ecdf”}, optional

How to represent the marginal density. Defaults to rcParams["plot.density_kind"]

triangle{“both”, “upper”, “lower”}, Defaults to “both”

Which triangle of the pair plot to plot.

plot_matrixPlotMatrix, optional
backend{“matplotlib”, “bokeh”, “plotly”, “none”}, optional

Plotting backend to use. Defaults to rcParams["plot.backend"]

labellerlabeller, optional
aes_by_visualsmapping, optional

Mapping of visuals to aesthetics that should use their mapping in plot_matrix when plotted. Valid keys are the same as for visuals. By default, there are no aesthetic mappings at all

visualsmapping of {strmapping or False}, optional

Valid keys are:

  • scatter -> passed to scatter_couple

  • divergence -> passed to scatter_couple. Defaults to False.

  • dist -> depending on the value of marginal_kind passed to:

    • “kde” -> passed to line_xy

    • “ecdf” -> passed to ecdf_line

    • “hist” -> passed to :func: hist

  • credible_interval -> passed to line_x

  • point_estimate -> passed to scatter_x

  • point_estimate_text -> passed to point_estimate_text

  • label -> Keyword arguments passed to label_plot.

    Used to customize the variable name labels on the diagonal. Applied only if marginal=False.

  • xlabel -> passed to labelled_x.

    used to customize the xaxis labels on the bottom-most plots or diagonal plots depending upon the value of triangle. If triangle is “lower” or “both” then it is used to map bottom-most row plots by using arviz_plots.PlotMatrix.map_row method and if triangle is “upper” then it is used to map diagonal plots by using arviz_plots.PlotMatrix.map method.It is applied only if marginal=True, since in this case diagonal plots won’t have labels to map variables to columns.

  • ylabel -> passed to labelled_y.

    used to customize the yaxis labels on the left-most plots. It is applied, only if triangle is “lower” or “both” and marginal=True, by using arviz_plots.PlotMatrix.map_col method. Not applied if triangle is “upper” or marginal=False.

  • remove_axis -> not passed anywhere.

    It can only be set to False to disable the default removal of x and y axes from the plots of other half triangle. If triangle is “upper” then the lower triangle plot’s axes will be removed and if triangle is “lower” then the upper triangle axes will be removed, in case if it is not set False manually.

statsmapping, optional

Valid keys are:

  • dist -> passed to kde, ecdf, …

  • credible_interval -> passed to eti or hdi

  • point_estimate -> passed to mean, median or mode

**pc_kwargs

Passed to arviz_plots.PlotMatrix

Returns:
PlotMatrix

Examples

plot_pair with triangle set to “upper” and marginal=True with marginal_kind set to “ecdf”. In this case, since triangle is “upper”, so the xlabels are mapped to the diagonal plots. marginals are plotted on the diagonal and the point_estimate and credible_interval are set to False by default. Also since marginal=True, so sharex is set to “col”, while sharey is not set to anything by default.

>>> from arviz_plots import plot_pair, style
>>> style.use("arviz-variat")
>>> from arviz_base import load_arviz_data
>>> dt = load_arviz_data('centered_eight')
>>> plot_pair(
>>>     dt,
>>>     var_names=["mu", "tau"],
>>>     visuals={"divergence": True},
>>>     marginal=True,
>>>     marginal_kind="ecdf",
>>>     triangle="upper",
>>> )
../../_images/arviz_plots-plot_pair-1.png

plot_pair with triangle set to “both”, so in this case the xlabels are mapped to the bottom-most plots and ylabels are mapped to the left-most plots. In this example we set color as “red” for credible_interval and point_estimate, which enables credible_interval and point_estimate. By default marginal is set to True and marginal_kind is set to rcParams["plot.density_kind"].

>>> visuals = {"credible_interval":{"color":"red"},"point_estimate":{"color":"red"}}
>>> plot_pair(
>>>     dt,
>>>     var_names=["mu", "tau"],
>>>     visuals=visuals,
>>>     triangle="both",
>>> )
../../_images/arviz_plots-plot_pair-2.png

plot_pair with marginal=False and triangle set to “upper”. In this case, since marginal=False, so xlabel and ylabel are disabled by default, and diagonal plots contain variable names as labels. xticks and yticks are also set on diagonal plots along with ticklabels, to map ticks to rows and columns. Since marginal=False, so sharex is set to “col” and sharey is set to “row” by default.

>>> plot_pair(
>>>     dt,
>>>     coords = {"school":"Choate"},
>>>     visuals={"divergence": True},
>>>     marginal=False,
>>>     triangle="upper",
>>> )
../../_images/arviz_plots-plot_pair-3.png