We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Return value of plot_pair is numvars the same
The return value of `plot_pair` is a list that contains `numvars` times the array of subplots. I guess it comes from the original version with gridspec. 

Line 168 defines `axs` empty list, which is no longer used, line 219 appends `ax` to `axs`, but `ax` already contains all the subplots. Eventually, `axs` is returned instead of `ax`.

In addition, maybe the docstring should be updated to specify that `ax` (both as input and as return value) is actually an array of axes, not an axes object. It cannot be a single axes because there are many, but I am not sure if everyone will see it right away.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `arviz/plots/pairplot.py`
Content:
```
1 """Plot a scatter or hexbin of sampled parameters."""
2 import numpy as np
3 import matplotlib.pyplot as plt
4 from matplotlib.ticker import NullFormatter
5 from mpl_toolkits.axes_grid1 import make_axes_locatable
6 
7 from ..data import convert_to_dataset
8 from .kdeplot import plot_kde
9 from .plot_utils import _scale_fig_size, xarray_to_ndarray, get_coords
10 from ..utils import _var_names
11 
12 
13 def plot_pair(
14     data,
15     var_names=None,
16     coords=None,
17     figsize=None,
18     textsize=None,
19     kind="scatter",
20     gridsize="auto",
21     contour=True,
22     fill_last=True,
23     divergences=False,
24     colorbar=False,
25     ax=None,
26     divergences_kwargs=None,
27     plot_kwargs=None,
28 ):
29     """
30     Plot a scatter or hexbin matrix of the sampled parameters.
31 
32     Parameters
33     ----------
34     data : obj
35         Any object that can be converted to an az.InferenceData object
36         Refer to documentation of az.convert_to_dataset for details
37     var_names : list of variable names
38         Variables to be plotted, if None all variable are plotted
39     coords : mapping, optional
40         Coordinates of var_names to be plotted. Passed to `Dataset.sel`
41     figsize : figure size tuple
42         If None, size is (8 + numvars, 8 + numvars)
43     textsize: int
44         Text size for labels. If None it will be autoscaled based on figsize.
45     kind : str
46         Type of plot to display (kde or hexbin)
47     gridsize : int or (int, int), optional
48         Only works for kind=hexbin.
49         The number of hexagons in the x-direction. The corresponding number of hexagons in the
50         y-direction is chosen such that the hexagons are approximately regular.
51         Alternatively, gridsize can be a tuple with two elements specifying the number of hexagons
52         in the x-direction and the y-direction.
53     contour : bool
54         If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE. Defaults to True.
55     fill_last : bool
56         If True fill the last contour of the 2D KDE plot. Defaults to True.
57     divergences : Boolean
58         If True divergences will be plotted in a different color
59     colorbar : bool
60         If True a colorbar will be included as part of the plot (Defaults to False).
61         Only works when kind=hexbin
62     ax: axes
63         Matplotlib axes
64     divergences_kwargs : dicts, optional
65         Additional keywords passed to ax.scatter for divergences
66     plot_kwargs : dicts, optional
67         Additional keywords passed to ax.plot, az.plot_kde or ax.hexbin
68     Returns
69     -------
70     ax : matplotlib axes
71 
72     Examples
73     --------
74     KDE Pair Plot
75 
76     .. plot::
77         :context: close-figs
78 
79         >>> import arviz as az
80         >>> centered = az.load_arviz_data('centered_eight')
81         >>> coords = {'school': ['Choate', 'Deerfield']}
82         >>> az.plot_pair(centered,
83         >>>             var_names=['theta', 'mu', 'tau'],
84         >>>             kind='kde',
85         >>>             coords=coords,
86         >>>             divergences=True,
87         >>>             textsize=18)
88 
89     Hexbin pair plot
90 
91     .. plot::
92         :context: close-figs
93 
94         >>> az.plot_pair(centered,
95         >>>             var_names=['theta', 'mu'],
96         >>>             coords=coords,
97         >>>             textsize=18,
98         >>>             kind='hexbin')
99 
100     Pair plot showing divergences
101 
102     .. plot::
103         :context: close-figs
104 
105         >>> az.plot_pair(centered,
106         ...             var_names=['theta', 'mu', 'tau'],
107         ...             coords=coords,
108         ...             divergences=True,
109         ...             textsize=18)
110     """
111     valid_kinds = ["scatter", "kde", "hexbin"]
112     if kind not in valid_kinds:
113         raise ValueError(
114             ("Plot type {} not recognized." "Plot type must be in {}").format(kind, valid_kinds)
115         )
116 
117     if coords is None:
118         coords = {}
119 
120     if plot_kwargs is None:
121         plot_kwargs = {}
122 
123     if kind == "scatter":
124         plot_kwargs.setdefault("marker", ".")
125         plot_kwargs.setdefault("lw", 0)
126 
127     if divergences_kwargs is None:
128         divergences_kwargs = {}
129 
130     divergences_kwargs.setdefault("marker", "o")
131     divergences_kwargs.setdefault("markeredgecolor", "k")
132     divergences_kwargs.setdefault("color", "C1")
133     divergences_kwargs.setdefault("lw", 0)
134 
135     # Get posterior draws and combine chains
136     posterior_data = convert_to_dataset(data, group="posterior")
137     var_names = _var_names(var_names, posterior_data)
138     flat_var_names, _posterior = xarray_to_ndarray(
139         get_coords(posterior_data, coords), var_names=var_names, combined=True
140     )
141 
142     # Get diverging draws and combine chains
143     if divergences:
144         divergent_data = convert_to_dataset(data, group="sample_stats")
145         _, diverging_mask = xarray_to_ndarray(
146             divergent_data, var_names=("diverging",), combined=True
147         )
148         diverging_mask = np.squeeze(diverging_mask)
149 
150     if gridsize == "auto":
151         gridsize = int(len(_posterior[0]) ** 0.35)
152 
153     numvars = len(flat_var_names)
154 
155     if numvars < 2:
156         raise Exception("Number of variables to be plotted must be 2 or greater.")
157 
158     if numvars == 2:
159         (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(
160             figsize, textsize, numvars - 1, numvars - 1
161         )
162 
163         if ax is None:
164             fig, ax = plt.subplots(figsize=figsize, constrained_layout=True)
165 
166         if kind == "scatter":
167             ax.plot(_posterior[0], _posterior[1], **plot_kwargs)
168         elif kind == "kde":
169             plot_kde(
170                 _posterior[0],
171                 _posterior[1],
172                 contour=contour,
173                 fill_last=fill_last,
174                 ax=ax,
175                 **plot_kwargs
176             )
177         else:
178             hexbin = ax.hexbin(
179                 _posterior[0], _posterior[1], mincnt=1, gridsize=gridsize, **plot_kwargs
180             )
181             ax.grid(False)
182 
183         if kind == "hexbin" and colorbar:
184             cbar = ax.figure.colorbar(hexbin, ticks=[hexbin.norm.vmin, hexbin.norm.vmax], ax=ax)
185             cbar.ax.set_yticklabels(["low", "high"], fontsize=ax_labelsize)
186 
187         if divergences:
188             ax.plot(
189                 _posterior[0][diverging_mask], _posterior[1][diverging_mask], **divergences_kwargs
190             )
191 
192         ax.set_xlabel("{}".format(flat_var_names[0]), fontsize=ax_labelsize, wrap=True)
193         ax.set_ylabel("{}".format(flat_var_names[1]), fontsize=ax_labelsize, wrap=True)
194         ax.tick_params(labelsize=xt_labelsize)
195         axs = ax
196 
197     else:
198         (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(
199             figsize, textsize, numvars - 2, numvars - 2
200         )
201 
202         if ax is None:
203             fig, ax = plt.subplots(
204                 numvars - 1, numvars - 1, figsize=figsize, constrained_layout=True
205             )
206         axs = []
207         hexbin_values = []
208         for i in range(0, numvars - 1):
209             var1 = _posterior[i]
210 
211             for j in range(0, numvars - 1):
212                 if j < i:
213                     ax[j, i].axis("off")
214                     continue
215 
216                 var2 = _posterior[j + 1]
217 
218                 if kind == "scatter":
219                     ax[j, i].plot(var1, var2, **plot_kwargs)
220 
221                 elif kind == "kde":
222                     plot_kde(
223                         var1, var2, contour=contour, fill_last=fill_last, ax=ax[j, i], **plot_kwargs
224                     )
225 
226                 else:
227                     ax[j, i].grid(False)
228                     hexbin = ax[j, i].hexbin(var1, var2, mincnt=1, gridsize=gridsize, **plot_kwargs)
229                 if kind == "hexbin" and colorbar:
230                     hexbin_values.append(hexbin.norm.vmin)
231                     hexbin_values.append(hexbin.norm.vmax)
232                     if j == i == 0 and colorbar:
233                         divider = make_axes_locatable(ax[0, 1])
234                         cax = divider.append_axes("left", size="7%")
235                         cbar = fig.colorbar(
236                             hexbin, ticks=[hexbin.norm.vmin, hexbin.norm.vmax], cax=cax
237                         )
238                         cbar.ax.set_yticklabels(["low", "high"], fontsize=ax_labelsize)
239 
240                 if divergences:
241                     ax[j, i].plot(var1[diverging_mask], var2[diverging_mask], **divergences_kwargs)
242 
243                 if j + 1 != numvars - 1:
244                     ax[j, i].axes.get_xaxis().set_major_formatter(NullFormatter())
245                 else:
246                     ax[j, i].set_xlabel(
247                         "{}".format(flat_var_names[i]), fontsize=ax_labelsize, wrap=True
248                     )
249                 if i != 0:
250                     ax[j, i].axes.get_yaxis().set_major_formatter(NullFormatter())
251                 else:
252                     ax[j, i].set_ylabel(
253                         "{}".format(flat_var_names[j + 1]), fontsize=ax_labelsize, wrap=True
254                     )
255 
256                 ax[j, i].tick_params(labelsize=xt_labelsize)
257                 axs.append(ax)
258 
259     return axs
260
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/arviz/plots/pairplot.py b/arviz/plots/pairplot.py
--- a/arviz/plots/pairplot.py
+++ b/arviz/plots/pairplot.py
@@ -192,7 +192,6 @@
         ax.set_xlabel("{}".format(flat_var_names[0]), fontsize=ax_labelsize, wrap=True)
         ax.set_ylabel("{}".format(flat_var_names[1]), fontsize=ax_labelsize, wrap=True)
         ax.tick_params(labelsize=xt_labelsize)
-        axs = ax
 
     else:
         (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(
@@ -203,7 +202,6 @@
             fig, ax = plt.subplots(
                 numvars - 1, numvars - 1, figsize=figsize, constrained_layout=True
             )
-        axs = []
         hexbin_values = []
         for i in range(0, numvars - 1):
             var1 = _posterior[i]
@@ -254,6 +252,5 @@
                     )
 
                 ax[j, i].tick_params(labelsize=xt_labelsize)
-                axs.append(ax)
 
-    return axs
+    return ax

{"golden_diff": "diff --git a/arviz/plots/pairplot.py b/arviz/plots/pairplot.py\n--- a/arviz/plots/pairplot.py\n+++ b/arviz/plots/pairplot.py\n@@ -192,7 +192,6 @@\n         ax.set_xlabel(\"{}\".format(flat_var_names[0]), fontsize=ax_labelsize, wrap=True)\n         ax.set_ylabel(\"{}\".format(flat_var_names[1]), fontsize=ax_labelsize, wrap=True)\n         ax.tick_params(labelsize=xt_labelsize)\n-        axs = ax\n \n     else:\n         (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(\n@@ -203,7 +202,6 @@\n             fig, ax = plt.subplots(\n                 numvars - 1, numvars - 1, figsize=figsize, constrained_layout=True\n             )\n-        axs = []\n         hexbin_values = []\n         for i in range(0, numvars - 1):\n             var1 = _posterior[i]\n@@ -254,6 +252,5 @@\n                     )\n \n                 ax[j, i].tick_params(labelsize=xt_labelsize)\n-                axs.append(ax)\n \n-    return axs\n+    return ax\n", "issue": "Return value of plot_pair is numvars the same\nThe return value of `plot_pair` is a list that contains `numvars` times the array of subplots. I guess it comes from the original version with gridspec. \r\n\r\nLine 168 defines `axs` empty list, which is no longer used, line 219 appends `ax` to `axs`, but `ax` already contains all the subplots. Eventually, `axs` is returned instead of `ax`.\r\n\r\nIn addition, maybe the docstring should be updated to specify that `ax` (both as input and as return value) is actually an array of axes, not an axes object. It cannot be a single axes because there are many, but I am not sure if everyone will see it right away.\r\n\n", "before_files": [{"content": "\"\"\"Plot a scatter or hexbin of sampled parameters.\"\"\"\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom matplotlib.ticker import NullFormatter\nfrom mpl_toolkits.axes_grid1 import make_axes_locatable\n\nfrom ..data import convert_to_dataset\nfrom .kdeplot import plot_kde\nfrom .plot_utils import _scale_fig_size, xarray_to_ndarray, get_coords\nfrom ..utils import _var_names\n\n\ndef plot_pair(\n    data,\n    var_names=None,\n    coords=None,\n    figsize=None,\n    textsize=None,\n    kind=\"scatter\",\n    gridsize=\"auto\",\n    contour=True,\n    fill_last=True,\n    divergences=False,\n    colorbar=False,\n    ax=None,\n    divergences_kwargs=None,\n    plot_kwargs=None,\n):\n    \"\"\"\n    Plot a scatter or hexbin matrix of the sampled parameters.\n\n    Parameters\n    ----------\n    data : obj\n        Any object that can be converted to an az.InferenceData object\n        Refer to documentation of az.convert_to_dataset for details\n    var_names : list of variable names\n        Variables to be plotted, if None all variable are plotted\n    coords : mapping, optional\n        Coordinates of var_names to be plotted. Passed to `Dataset.sel`\n    figsize : figure size tuple\n        If None, size is (8 + numvars, 8 + numvars)\n    textsize: int\n        Text size for labels. If None it will be autoscaled based on figsize.\n    kind : str\n        Type of plot to display (kde or hexbin)\n    gridsize : int or (int, int), optional\n        Only works for kind=hexbin.\n        The number of hexagons in the x-direction. The corresponding number of hexagons in the\n        y-direction is chosen such that the hexagons are approximately regular.\n        Alternatively, gridsize can be a tuple with two elements specifying the number of hexagons\n        in the x-direction and the y-direction.\n    contour : bool\n        If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE. Defaults to True.\n    fill_last : bool\n        If True fill the last contour of the 2D KDE plot. Defaults to True.\n    divergences : Boolean\n        If True divergences will be plotted in a different color\n    colorbar : bool\n        If True a colorbar will be included as part of the plot (Defaults to False).\n        Only works when kind=hexbin\n    ax: axes\n        Matplotlib axes\n    divergences_kwargs : dicts, optional\n        Additional keywords passed to ax.scatter for divergences\n    plot_kwargs : dicts, optional\n        Additional keywords passed to ax.plot, az.plot_kde or ax.hexbin\n    Returns\n    -------\n    ax : matplotlib axes\n\n    Examples\n    --------\n    KDE Pair Plot\n\n    .. plot::\n        :context: close-figs\n\n        >>> import arviz as az\n        >>> centered = az.load_arviz_data('centered_eight')\n        >>> coords = {'school': ['Choate', 'Deerfield']}\n        >>> az.plot_pair(centered,\n        >>>             var_names=['theta', 'mu', 'tau'],\n        >>>             kind='kde',\n        >>>             coords=coords,\n        >>>             divergences=True,\n        >>>             textsize=18)\n\n    Hexbin pair plot\n\n    .. plot::\n        :context: close-figs\n\n        >>> az.plot_pair(centered,\n        >>>             var_names=['theta', 'mu'],\n        >>>             coords=coords,\n        >>>             textsize=18,\n        >>>             kind='hexbin')\n\n    Pair plot showing divergences\n\n    .. plot::\n        :context: close-figs\n\n        >>> az.plot_pair(centered,\n        ...             var_names=['theta', 'mu', 'tau'],\n        ...             coords=coords,\n        ...             divergences=True,\n        ...             textsize=18)\n    \"\"\"\n    valid_kinds = [\"scatter\", \"kde\", \"hexbin\"]\n    if kind not in valid_kinds:\n        raise ValueError(\n            (\"Plot type {} not recognized.\" \"Plot type must be in {}\").format(kind, valid_kinds)\n        )\n\n    if coords is None:\n        coords = {}\n\n    if plot_kwargs is None:\n        plot_kwargs = {}\n\n    if kind == \"scatter\":\n        plot_kwargs.setdefault(\"marker\", \".\")\n        plot_kwargs.setdefault(\"lw\", 0)\n\n    if divergences_kwargs is None:\n        divergences_kwargs = {}\n\n    divergences_kwargs.setdefault(\"marker\", \"o\")\n    divergences_kwargs.setdefault(\"markeredgecolor\", \"k\")\n    divergences_kwargs.setdefault(\"color\", \"C1\")\n    divergences_kwargs.setdefault(\"lw\", 0)\n\n    # Get posterior draws and combine chains\n    posterior_data = convert_to_dataset(data, group=\"posterior\")\n    var_names = _var_names(var_names, posterior_data)\n    flat_var_names, _posterior = xarray_to_ndarray(\n        get_coords(posterior_data, coords), var_names=var_names, combined=True\n    )\n\n    # Get diverging draws and combine chains\n    if divergences:\n        divergent_data = convert_to_dataset(data, group=\"sample_stats\")\n        _, diverging_mask = xarray_to_ndarray(\n            divergent_data, var_names=(\"diverging\",), combined=True\n        )\n        diverging_mask = np.squeeze(diverging_mask)\n\n    if gridsize == \"auto\":\n        gridsize = int(len(_posterior[0]) ** 0.35)\n\n    numvars = len(flat_var_names)\n\n    if numvars < 2:\n        raise Exception(\"Number of variables to be plotted must be 2 or greater.\")\n\n    if numvars == 2:\n        (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(\n            figsize, textsize, numvars - 1, numvars - 1\n        )\n\n        if ax is None:\n            fig, ax = plt.subplots(figsize=figsize, constrained_layout=True)\n\n        if kind == \"scatter\":\n            ax.plot(_posterior[0], _posterior[1], **plot_kwargs)\n        elif kind == \"kde\":\n            plot_kde(\n                _posterior[0],\n                _posterior[1],\n                contour=contour,\n                fill_last=fill_last,\n                ax=ax,\n                **plot_kwargs\n            )\n        else:\n            hexbin = ax.hexbin(\n                _posterior[0], _posterior[1], mincnt=1, gridsize=gridsize, **plot_kwargs\n            )\n            ax.grid(False)\n\n        if kind == \"hexbin\" and colorbar:\n            cbar = ax.figure.colorbar(hexbin, ticks=[hexbin.norm.vmin, hexbin.norm.vmax], ax=ax)\n            cbar.ax.set_yticklabels([\"low\", \"high\"], fontsize=ax_labelsize)\n\n        if divergences:\n            ax.plot(\n                _posterior[0][diverging_mask], _posterior[1][diverging_mask], **divergences_kwargs\n            )\n\n        ax.set_xlabel(\"{}\".format(flat_var_names[0]), fontsize=ax_labelsize, wrap=True)\n        ax.set_ylabel(\"{}\".format(flat_var_names[1]), fontsize=ax_labelsize, wrap=True)\n        ax.tick_params(labelsize=xt_labelsize)\n        axs = ax\n\n    else:\n        (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(\n            figsize, textsize, numvars - 2, numvars - 2\n        )\n\n        if ax is None:\n            fig, ax = plt.subplots(\n                numvars - 1, numvars - 1, figsize=figsize, constrained_layout=True\n            )\n        axs = []\n        hexbin_values = []\n        for i in range(0, numvars - 1):\n            var1 = _posterior[i]\n\n            for j in range(0, numvars - 1):\n                if j < i:\n                    ax[j, i].axis(\"off\")\n                    continue\n\n                var2 = _posterior[j + 1]\n\n                if kind == \"scatter\":\n                    ax[j, i].plot(var1, var2, **plot_kwargs)\n\n                elif kind == \"kde\":\n                    plot_kde(\n                        var1, var2, contour=contour, fill_last=fill_last, ax=ax[j, i], **plot_kwargs\n                    )\n\n                else:\n                    ax[j, i].grid(False)\n                    hexbin = ax[j, i].hexbin(var1, var2, mincnt=1, gridsize=gridsize, **plot_kwargs)\n                if kind == \"hexbin\" and colorbar:\n                    hexbin_values.append(hexbin.norm.vmin)\n                    hexbin_values.append(hexbin.norm.vmax)\n                    if j == i == 0 and colorbar:\n                        divider = make_axes_locatable(ax[0, 1])\n                        cax = divider.append_axes(\"left\", size=\"7%\")\n                        cbar = fig.colorbar(\n                            hexbin, ticks=[hexbin.norm.vmin, hexbin.norm.vmax], cax=cax\n                        )\n                        cbar.ax.set_yticklabels([\"low\", \"high\"], fontsize=ax_labelsize)\n\n                if divergences:\n                    ax[j, i].plot(var1[diverging_mask], var2[diverging_mask], **divergences_kwargs)\n\n                if j + 1 != numvars - 1:\n                    ax[j, i].axes.get_xaxis().set_major_formatter(NullFormatter())\n                else:\n                    ax[j, i].set_xlabel(\n                        \"{}\".format(flat_var_names[i]), fontsize=ax_labelsize, wrap=True\n                    )\n                if i != 0:\n                    ax[j, i].axes.get_yaxis().set_major_formatter(NullFormatter())\n                else:\n                    ax[j, i].set_ylabel(\n                        \"{}\".format(flat_var_names[j + 1]), fontsize=ax_labelsize, wrap=True\n                    )\n\n                ax[j, i].tick_params(labelsize=xt_labelsize)\n                axs.append(ax)\n\n    return axs\n", "path": "arviz/plots/pairplot.py"}], "after_files": [{"content": "\"\"\"Plot a scatter or hexbin of sampled parameters.\"\"\"\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom matplotlib.ticker import NullFormatter\nfrom mpl_toolkits.axes_grid1 import make_axes_locatable\n\nfrom ..data import convert_to_dataset\nfrom .kdeplot import plot_kde\nfrom .plot_utils import _scale_fig_size, xarray_to_ndarray, get_coords\nfrom ..utils import _var_names\n\n\ndef plot_pair(\n    data,\n    var_names=None,\n    coords=None,\n    figsize=None,\n    textsize=None,\n    kind=\"scatter\",\n    gridsize=\"auto\",\n    contour=True,\n    fill_last=True,\n    divergences=False,\n    colorbar=False,\n    ax=None,\n    divergences_kwargs=None,\n    plot_kwargs=None,\n):\n    \"\"\"\n    Plot a scatter or hexbin matrix of the sampled parameters.\n\n    Parameters\n    ----------\n    data : obj\n        Any object that can be converted to an az.InferenceData object\n        Refer to documentation of az.convert_to_dataset for details\n    var_names : list of variable names\n        Variables to be plotted, if None all variable are plotted\n    coords : mapping, optional\n        Coordinates of var_names to be plotted. Passed to `Dataset.sel`\n    figsize : figure size tuple\n        If None, size is (8 + numvars, 8 + numvars)\n    textsize: int\n        Text size for labels. If None it will be autoscaled based on figsize.\n    kind : str\n        Type of plot to display (kde or hexbin)\n    gridsize : int or (int, int), optional\n        Only works for kind=hexbin.\n        The number of hexagons in the x-direction. The corresponding number of hexagons in the\n        y-direction is chosen such that the hexagons are approximately regular.\n        Alternatively, gridsize can be a tuple with two elements specifying the number of hexagons\n        in the x-direction and the y-direction.\n    contour : bool\n        If True plot the 2D KDE using contours, otherwise plot a smooth 2D KDE. Defaults to True.\n    fill_last : bool\n        If True fill the last contour of the 2D KDE plot. Defaults to True.\n    divergences : Boolean\n        If True divergences will be plotted in a different color\n    colorbar : bool\n        If True a colorbar will be included as part of the plot (Defaults to False).\n        Only works when kind=hexbin\n    ax: axes\n        Matplotlib axes\n    divergences_kwargs : dicts, optional\n        Additional keywords passed to ax.scatter for divergences\n    plot_kwargs : dicts, optional\n        Additional keywords passed to ax.plot, az.plot_kde or ax.hexbin\n    Returns\n    -------\n    ax : matplotlib axes\n\n    Examples\n    --------\n    KDE Pair Plot\n\n    .. plot::\n        :context: close-figs\n\n        >>> import arviz as az\n        >>> centered = az.load_arviz_data('centered_eight')\n        >>> coords = {'school': ['Choate', 'Deerfield']}\n        >>> az.plot_pair(centered,\n        >>>             var_names=['theta', 'mu', 'tau'],\n        >>>             kind='kde',\n        >>>             coords=coords,\n        >>>             divergences=True,\n        >>>             textsize=18)\n\n    Hexbin pair plot\n\n    .. plot::\n        :context: close-figs\n\n        >>> az.plot_pair(centered,\n        >>>             var_names=['theta', 'mu'],\n        >>>             coords=coords,\n        >>>             textsize=18,\n        >>>             kind='hexbin')\n\n    Pair plot showing divergences\n\n    .. plot::\n        :context: close-figs\n\n        >>> az.plot_pair(centered,\n        ...             var_names=['theta', 'mu', 'tau'],\n        ...             coords=coords,\n        ...             divergences=True,\n        ...             textsize=18)\n    \"\"\"\n    valid_kinds = [\"scatter\", \"kde\", \"hexbin\"]\n    if kind not in valid_kinds:\n        raise ValueError(\n            (\"Plot type {} not recognized.\" \"Plot type must be in {}\").format(kind, valid_kinds)\n        )\n\n    if coords is None:\n        coords = {}\n\n    if plot_kwargs is None:\n        plot_kwargs = {}\n\n    if kind == \"scatter\":\n        plot_kwargs.setdefault(\"marker\", \".\")\n        plot_kwargs.setdefault(\"lw\", 0)\n\n    if divergences_kwargs is None:\n        divergences_kwargs = {}\n\n    divergences_kwargs.setdefault(\"marker\", \"o\")\n    divergences_kwargs.setdefault(\"markeredgecolor\", \"k\")\n    divergences_kwargs.setdefault(\"color\", \"C1\")\n    divergences_kwargs.setdefault(\"lw\", 0)\n\n    # Get posterior draws and combine chains\n    posterior_data = convert_to_dataset(data, group=\"posterior\")\n    var_names = _var_names(var_names, posterior_data)\n    flat_var_names, _posterior = xarray_to_ndarray(\n        get_coords(posterior_data, coords), var_names=var_names, combined=True\n    )\n\n    # Get diverging draws and combine chains\n    if divergences:\n        divergent_data = convert_to_dataset(data, group=\"sample_stats\")\n        _, diverging_mask = xarray_to_ndarray(\n            divergent_data, var_names=(\"diverging\",), combined=True\n        )\n        diverging_mask = np.squeeze(diverging_mask)\n\n    if gridsize == \"auto\":\n        gridsize = int(len(_posterior[0]) ** 0.35)\n\n    numvars = len(flat_var_names)\n\n    if numvars < 2:\n        raise Exception(\"Number of variables to be plotted must be 2 or greater.\")\n\n    if numvars == 2:\n        (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(\n            figsize, textsize, numvars - 1, numvars - 1\n        )\n\n        if ax is None:\n            fig, ax = plt.subplots(figsize=figsize, constrained_layout=True)\n\n        if kind == \"scatter\":\n            ax.plot(_posterior[0], _posterior[1], **plot_kwargs)\n        elif kind == \"kde\":\n            plot_kde(\n                _posterior[0],\n                _posterior[1],\n                contour=contour,\n                fill_last=fill_last,\n                ax=ax,\n                **plot_kwargs\n            )\n        else:\n            hexbin = ax.hexbin(\n                _posterior[0], _posterior[1], mincnt=1, gridsize=gridsize, **plot_kwargs\n            )\n            ax.grid(False)\n\n        if kind == \"hexbin\" and colorbar:\n            cbar = ax.figure.colorbar(hexbin, ticks=[hexbin.norm.vmin, hexbin.norm.vmax], ax=ax)\n            cbar.ax.set_yticklabels([\"low\", \"high\"], fontsize=ax_labelsize)\n\n        if divergences:\n            ax.plot(\n                _posterior[0][diverging_mask], _posterior[1][diverging_mask], **divergences_kwargs\n            )\n\n        ax.set_xlabel(\"{}\".format(flat_var_names[0]), fontsize=ax_labelsize, wrap=True)\n        ax.set_ylabel(\"{}\".format(flat_var_names[1]), fontsize=ax_labelsize, wrap=True)\n        ax.tick_params(labelsize=xt_labelsize)\n\n    else:\n        (figsize, ax_labelsize, _, xt_labelsize, _, _) = _scale_fig_size(\n            figsize, textsize, numvars - 2, numvars - 2\n        )\n\n        if ax is None:\n            fig, ax = plt.subplots(\n                numvars - 1, numvars - 1, figsize=figsize, constrained_layout=True\n            )\n        hexbin_values = []\n        for i in range(0, numvars - 1):\n            var1 = _posterior[i]\n\n            for j in range(0, numvars - 1):\n                if j < i:\n                    ax[j, i].axis(\"off\")\n                    continue\n\n                var2 = _posterior[j + 1]\n\n                if kind == \"scatter\":\n                    ax[j, i].plot(var1, var2, **plot_kwargs)\n\n                elif kind == \"kde\":\n                    plot_kde(\n                        var1, var2, contour=contour, fill_last=fill_last, ax=ax[j, i], **plot_kwargs\n                    )\n\n                else:\n                    ax[j, i].grid(False)\n                    hexbin = ax[j, i].hexbin(var1, var2, mincnt=1, gridsize=gridsize, **plot_kwargs)\n                if kind == \"hexbin\" and colorbar:\n                    hexbin_values.append(hexbin.norm.vmin)\n                    hexbin_values.append(hexbin.norm.vmax)\n                    if j == i == 0 and colorbar:\n                        divider = make_axes_locatable(ax[0, 1])\n                        cax = divider.append_axes(\"left\", size=\"7%\")\n                        cbar = fig.colorbar(\n                            hexbin, ticks=[hexbin.norm.vmin, hexbin.norm.vmax], cax=cax\n                        )\n                        cbar.ax.set_yticklabels([\"low\", \"high\"], fontsize=ax_labelsize)\n\n                if divergences:\n                    ax[j, i].plot(var1[diverging_mask], var2[diverging_mask], **divergences_kwargs)\n\n                if j + 1 != numvars - 1:\n                    ax[j, i].axes.get_xaxis().set_major_formatter(NullFormatter())\n                else:\n                    ax[j, i].set_xlabel(\n                        \"{}\".format(flat_var_names[i]), fontsize=ax_labelsize, wrap=True\n                    )\n                if i != 0:\n                    ax[j, i].axes.get_yaxis().set_major_formatter(NullFormatter())\n                else:\n                    ax[j, i].set_ylabel(\n                        \"{}\".format(flat_var_names[j + 1]), fontsize=ax_labelsize, wrap=True\n                    )\n\n                ax[j, i].tick_params(labelsize=xt_labelsize)\n\n    return ax\n", "path": "arviz/plots/pairplot.py"}]}