We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Add API docs for plot_ppc
https://arviz-devs.github.io/arviz/generated/arviz.plot_ppc.html#arviz.plot_ppc

See Posterior Docs for example
https://arviz-devs.github.io/arviz/generated/arviz.plot_posterior.html#arviz.plot_posterior

--- 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/ppcplot.py`
Content:
```
1 """Posterior predictive plot."""
2 import numpy as np
3 from .kdeplot import plot_kde, _fast_kde
4 from .plot_utils import _scale_fig_size, _create_axes_grid, default_grid
5 
6 
7 def plot_ppc(
8     data, kind="density", alpha=0.2, mean=True, figsize=None, textsize=None, data_pairs=None
9 ):
10     """
11     Plot for Posterior Predictive checks.
12 
13     Note that this plot will flatten out any dimensions in the posterior predictive variables.
14 
15     Parameters
16     ----------
17     data : Array-like
18         Observed values
19     kind : str
20         Type of plot to display (density or cumulative)
21     alpha : float
22         Opacity of posterior predictive density curves
23     mean : bool
24         Whether or not to plot the mean posterior predictive distribution. Defaults to True
25     figsize : tuple
26         Figure size. If None it will be defined automatically.
27     textsize: float
28         Text size scaling factor for labels, titles and lines. If None it will be autoscaled based
29         on figsize.
30     data_pairs : dict
31         Dictionary containing relations between observed data and posterior predictive data.
32         Dictionary structure:
33             Key = data var_name
34             Value = posterior predictive var_name
35         Example: `data_pairs = {'y' : 'y_hat'}`
36 
37     Returns
38     -------
39     axes : matplotlib axes
40     """
41     for group in ("posterior_predictive", "observed_data"):
42         if not hasattr(data, group):
43             raise TypeError(
44                 '`data` argument must have the group "{group}" for ppcplot'.format(group=group)
45             )
46 
47     if kind.lower() not in ("density", "cumulative"):
48         raise TypeError("`kind` argument must be either `density` or `cumulative`")
49 
50     if data_pairs is None:
51         data_pairs = {}
52 
53     observed = data.observed_data
54     posterior_predictive = data.posterior_predictive
55 
56     rows, cols = default_grid(len(observed.data_vars))
57 
58     (figsize, ax_labelsize, _, xt_labelsize, linewidth, _) = _scale_fig_size(
59         figsize, textsize, rows, cols
60     )
61 
62     _, axes = _create_axes_grid(len(observed.data_vars), rows, cols, figsize=figsize)
63 
64     for ax, var_name in zip(np.atleast_1d(axes), observed.data_vars):
65         dtype = observed[var_name].dtype.kind
66         if kind == "density":
67             if dtype == "f":
68                 plot_kde(
69                     observed[var_name].values.flatten(),
70                     label="Observed {}".format(var_name),
71                     plot_kwargs={"color": "k", "linewidth": linewidth, "zorder": 3},
72                     fill_kwargs={"alpha": 0},
73                     ax=ax,
74                 )
75             else:
76                 vals = observed[var_name].values.flatten()
77                 nbins = round(len(vals) ** 0.5)
78                 hist, bin_edges = np.histogram(vals, bins=nbins, density=True)
79                 hist = np.concatenate((hist[:1], hist))
80                 ax.plot(
81                     bin_edges,
82                     hist,
83                     label="Observed {}".format(var_name),
84                     color="k",
85                     linewidth=linewidth,
86                     zorder=3,
87                     drawstyle="steps-pre",
88                 )
89             pp_var_name = data_pairs.get(var_name, var_name)
90             # run plot_kde manually with one plot call
91             pp_densities = []
92             for _, chain_vals in posterior_predictive[pp_var_name].groupby("chain"):
93                 for _, vals in chain_vals.groupby("draw"):
94                     if dtype == "f":
95                         pp_density, lower, upper = _fast_kde(vals)
96                         pp_x = np.linspace(lower, upper, len(pp_density))
97                         pp_densities.extend([pp_x, pp_density])
98                     else:
99                         nbins = round(len(vals) ** 0.5)
100                         hist, bin_edges = np.histogram(vals, bins=nbins, density=True)
101                         hist = np.concatenate((hist[:1], hist))
102                         pp_densities.extend([bin_edges, hist])
103             plot_kwargs = {"color": "C5", "alpha": alpha, "linewidth": 0.5 * linewidth}
104             if dtype == "i":
105                 plot_kwargs["drawstyle"] = "steps-pre"
106             ax.plot(*pp_densities, **plot_kwargs)
107             ax.plot([], color="C5", label="Posterior predictive {}".format(pp_var_name))
108             if mean:
109                 if dtype == "f":
110                     plot_kde(
111                         posterior_predictive[pp_var_name].values.flatten(),
112                         plot_kwargs={
113                             "color": "C0",
114                             "linestyle": "--",
115                             "linewidth": linewidth,
116                             "zorder": 2,
117                         },
118                         label="Posterior predictive mean {}".format(pp_var_name),
119                         ax=ax,
120                     )
121                 else:
122                     vals = posterior_predictive[pp_var_name].values.flatten()
123                     nbins = round(len(vals) ** 0.5)
124                     hist, bin_edges = np.histogram(vals, bins=nbins, density=True)
125                     hist = np.concatenate((hist[:1], hist))
126                     ax.plot(
127                         bin_edges,
128                         hist,
129                         color="C0",
130                         linewidth=linewidth,
131                         label="Posterior predictive mean {}".format(pp_var_name),
132                         zorder=2,
133                         linestyle="--",
134                         drawstyle="steps-pre",
135                     )
136             if var_name != pp_var_name:
137                 xlabel = "{} / {}".format(var_name, pp_var_name)
138             else:
139                 xlabel = var_name
140             ax.set_xlabel(xlabel, fontsize=ax_labelsize)
141             ax.tick_params(labelsize=xt_labelsize)
142             ax.set_yticks([])
143 
144         elif kind == "cumulative":
145             if dtype == "f":
146                 ax.plot(
147                     *_empirical_cdf(observed[var_name].values.flatten()),
148                     color="k",
149                     linewidth=linewidth,
150                     label="Observed {}".format(var_name),
151                     zorder=3
152                 )
153             else:
154                 ax.plot(
155                     *_empirical_cdf(observed[var_name].values.flatten()),
156                     color="k",
157                     linewidth=linewidth,
158                     label="Observed {}".format(var_name),
159                     drawstyle="steps-pre",
160                     zorder=3
161                 )
162             pp_var_name = data_pairs.get(var_name, var_name)
163             # run plot_kde manually with one plot call
164             pp_densities = []
165             for _, chain_vals in posterior_predictive[pp_var_name].groupby("chain"):
166                 for _, vals in chain_vals.groupby("draw"):
167                     pp_x, pp_density = _empirical_cdf(vals)
168                     pp_densities.extend([pp_x, pp_density])
169             if dtype == "f":
170                 ax.plot(*pp_densities, alpha=alpha, color="C5", linewidth=linewidth)
171             else:
172                 ax.plot(
173                     *pp_densities,
174                     alpha=alpha,
175                     color="C5",
176                     drawstyle="steps-pre",
177                     linewidth=linewidth
178                 )
179             ax.plot([], color="C5", label="Posterior predictive {}".format(pp_var_name))
180             if mean:
181                 if dtype == "f":
182                     ax.plot(
183                         *_empirical_cdf(posterior_predictive[pp_var_name].values.flatten()),
184                         color="C0",
185                         linestyle="--",
186                         linewidth=linewidth,
187                         label="Posterior predictive mean {}".format(pp_var_name)
188                     )
189                 else:
190                     ax.plot(
191                         *_empirical_cdf(posterior_predictive[pp_var_name].values.flatten()),
192                         color="C0",
193                         linestyle="--",
194                         linewidth=linewidth,
195                         drawstyle="steps-pre",
196                         label="Posterior predictive mean {}".format(pp_var_name)
197                     )
198             if var_name != pp_var_name:
199                 xlabel = "{} / {}".format(var_name, pp_var_name)
200             else:
201                 xlabel = var_name
202             ax.set_xlabel(var_name, fontsize=ax_labelsize)
203             ax.set_yticks([0, 0.5, 1])
204         ax.legend(fontsize=xt_labelsize)
205     return axes
206 
207 
208 def _empirical_cdf(data):
209     """Compute empirical cdf of a numpy array.
210 
211     Parameters
212     ----------
213     data : np.array
214         1d array
215 
216     Returns
217     -------
218     np.array, np.array
219         x and y coordinates for the empirical cdf of the data
220     """
221     return np.sort(data), np.linspace(0, 1, len(data))
222
```
--- 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/ppcplot.py b/arviz/plots/ppcplot.py
--- a/arviz/plots/ppcplot.py
+++ b/arviz/plots/ppcplot.py
@@ -37,6 +37,25 @@
     Returns
     -------
     axes : matplotlib axes
+
+    Examples
+    --------
+    Plot the observed data KDE overlaid on posterior predictive KDEs.
+
+    .. plot::
+        :context: close-figs
+
+        >>> import arviz as az
+        >>> data = az.load_arviz_data('radon')
+        >>> az.plot_ppc(data)
+
+    Plot the overlay with empirical CDFs.
+
+    .. plot::
+        :context: close-figs
+
+        >>> az.plot_ppc(data, kind='cumulative')
+
     """
     for group in ("posterior_predictive", "observed_data"):
         if not hasattr(data, group):

{"golden_diff": "diff --git a/arviz/plots/ppcplot.py b/arviz/plots/ppcplot.py\n--- a/arviz/plots/ppcplot.py\n+++ b/arviz/plots/ppcplot.py\n@@ -37,6 +37,25 @@\n     Returns\n     -------\n     axes : matplotlib axes\n+\n+    Examples\n+    --------\n+    Plot the observed data KDE overlaid on posterior predictive KDEs.\n+\n+    .. plot::\n+        :context: close-figs\n+\n+        >>> import arviz as az\n+        >>> data = az.load_arviz_data('radon')\n+        >>> az.plot_ppc(data)\n+\n+    Plot the overlay with empirical CDFs.\n+\n+    .. plot::\n+        :context: close-figs\n+\n+        >>> az.plot_ppc(data, kind='cumulative')\n+\n     \"\"\"\n     for group in (\"posterior_predictive\", \"observed_data\"):\n         if not hasattr(data, group):\n", "issue": "Add API docs for plot_ppc\nhttps://arviz-devs.github.io/arviz/generated/arviz.plot_ppc.html#arviz.plot_ppc\r\n\r\nSee Posterior Docs for example\r\nhttps://arviz-devs.github.io/arviz/generated/arviz.plot_posterior.html#arviz.plot_posterior\n", "before_files": [{"content": "\"\"\"Posterior predictive plot.\"\"\"\nimport numpy as np\nfrom .kdeplot import plot_kde, _fast_kde\nfrom .plot_utils import _scale_fig_size, _create_axes_grid, default_grid\n\n\ndef plot_ppc(\n    data, kind=\"density\", alpha=0.2, mean=True, figsize=None, textsize=None, data_pairs=None\n):\n    \"\"\"\n    Plot for Posterior Predictive checks.\n\n    Note that this plot will flatten out any dimensions in the posterior predictive variables.\n\n    Parameters\n    ----------\n    data : Array-like\n        Observed values\n    kind : str\n        Type of plot to display (density or cumulative)\n    alpha : float\n        Opacity of posterior predictive density curves\n    mean : bool\n        Whether or not to plot the mean posterior predictive distribution. Defaults to True\n    figsize : tuple\n        Figure size. If None it will be defined automatically.\n    textsize: float\n        Text size scaling factor for labels, titles and lines. If None it will be autoscaled based\n        on figsize.\n    data_pairs : dict\n        Dictionary containing relations between observed data and posterior predictive data.\n        Dictionary structure:\n            Key = data var_name\n            Value = posterior predictive var_name\n        Example: `data_pairs = {'y' : 'y_hat'}`\n\n    Returns\n    -------\n    axes : matplotlib axes\n    \"\"\"\n    for group in (\"posterior_predictive\", \"observed_data\"):\n        if not hasattr(data, group):\n            raise TypeError(\n                '`data` argument must have the group \"{group}\" for ppcplot'.format(group=group)\n            )\n\n    if kind.lower() not in (\"density\", \"cumulative\"):\n        raise TypeError(\"`kind` argument must be either `density` or `cumulative`\")\n\n    if data_pairs is None:\n        data_pairs = {}\n\n    observed = data.observed_data\n    posterior_predictive = data.posterior_predictive\n\n    rows, cols = default_grid(len(observed.data_vars))\n\n    (figsize, ax_labelsize, _, xt_labelsize, linewidth, _) = _scale_fig_size(\n        figsize, textsize, rows, cols\n    )\n\n    _, axes = _create_axes_grid(len(observed.data_vars), rows, cols, figsize=figsize)\n\n    for ax, var_name in zip(np.atleast_1d(axes), observed.data_vars):\n        dtype = observed[var_name].dtype.kind\n        if kind == \"density\":\n            if dtype == \"f\":\n                plot_kde(\n                    observed[var_name].values.flatten(),\n                    label=\"Observed {}\".format(var_name),\n                    plot_kwargs={\"color\": \"k\", \"linewidth\": linewidth, \"zorder\": 3},\n                    fill_kwargs={\"alpha\": 0},\n                    ax=ax,\n                )\n            else:\n                vals = observed[var_name].values.flatten()\n                nbins = round(len(vals) ** 0.5)\n                hist, bin_edges = np.histogram(vals, bins=nbins, density=True)\n                hist = np.concatenate((hist[:1], hist))\n                ax.plot(\n                    bin_edges,\n                    hist,\n                    label=\"Observed {}\".format(var_name),\n                    color=\"k\",\n                    linewidth=linewidth,\n                    zorder=3,\n                    drawstyle=\"steps-pre\",\n                )\n            pp_var_name = data_pairs.get(var_name, var_name)\n            # run plot_kde manually with one plot call\n            pp_densities = []\n            for _, chain_vals in posterior_predictive[pp_var_name].groupby(\"chain\"):\n                for _, vals in chain_vals.groupby(\"draw\"):\n                    if dtype == \"f\":\n                        pp_density, lower, upper = _fast_kde(vals)\n                        pp_x = np.linspace(lower, upper, len(pp_density))\n                        pp_densities.extend([pp_x, pp_density])\n                    else:\n                        nbins = round(len(vals) ** 0.5)\n                        hist, bin_edges = np.histogram(vals, bins=nbins, density=True)\n                        hist = np.concatenate((hist[:1], hist))\n                        pp_densities.extend([bin_edges, hist])\n            plot_kwargs = {\"color\": \"C5\", \"alpha\": alpha, \"linewidth\": 0.5 * linewidth}\n            if dtype == \"i\":\n                plot_kwargs[\"drawstyle\"] = \"steps-pre\"\n            ax.plot(*pp_densities, **plot_kwargs)\n            ax.plot([], color=\"C5\", label=\"Posterior predictive {}\".format(pp_var_name))\n            if mean:\n                if dtype == \"f\":\n                    plot_kde(\n                        posterior_predictive[pp_var_name].values.flatten(),\n                        plot_kwargs={\n                            \"color\": \"C0\",\n                            \"linestyle\": \"--\",\n                            \"linewidth\": linewidth,\n                            \"zorder\": 2,\n                        },\n                        label=\"Posterior predictive mean {}\".format(pp_var_name),\n                        ax=ax,\n                    )\n                else:\n                    vals = posterior_predictive[pp_var_name].values.flatten()\n                    nbins = round(len(vals) ** 0.5)\n                    hist, bin_edges = np.histogram(vals, bins=nbins, density=True)\n                    hist = np.concatenate((hist[:1], hist))\n                    ax.plot(\n                        bin_edges,\n                        hist,\n                        color=\"C0\",\n                        linewidth=linewidth,\n                        label=\"Posterior predictive mean {}\".format(pp_var_name),\n                        zorder=2,\n                        linestyle=\"--\",\n                        drawstyle=\"steps-pre\",\n                    )\n            if var_name != pp_var_name:\n                xlabel = \"{} / {}\".format(var_name, pp_var_name)\n            else:\n                xlabel = var_name\n            ax.set_xlabel(xlabel, fontsize=ax_labelsize)\n            ax.tick_params(labelsize=xt_labelsize)\n            ax.set_yticks([])\n\n        elif kind == \"cumulative\":\n            if dtype == \"f\":\n                ax.plot(\n                    *_empirical_cdf(observed[var_name].values.flatten()),\n                    color=\"k\",\n                    linewidth=linewidth,\n                    label=\"Observed {}\".format(var_name),\n                    zorder=3\n                )\n            else:\n                ax.plot(\n                    *_empirical_cdf(observed[var_name].values.flatten()),\n                    color=\"k\",\n                    linewidth=linewidth,\n                    label=\"Observed {}\".format(var_name),\n                    drawstyle=\"steps-pre\",\n                    zorder=3\n                )\n            pp_var_name = data_pairs.get(var_name, var_name)\n            # run plot_kde manually with one plot call\n            pp_densities = []\n            for _, chain_vals in posterior_predictive[pp_var_name].groupby(\"chain\"):\n                for _, vals in chain_vals.groupby(\"draw\"):\n                    pp_x, pp_density = _empirical_cdf(vals)\n                    pp_densities.extend([pp_x, pp_density])\n            if dtype == \"f\":\n                ax.plot(*pp_densities, alpha=alpha, color=\"C5\", linewidth=linewidth)\n            else:\n                ax.plot(\n                    *pp_densities,\n                    alpha=alpha,\n                    color=\"C5\",\n                    drawstyle=\"steps-pre\",\n                    linewidth=linewidth\n                )\n            ax.plot([], color=\"C5\", label=\"Posterior predictive {}\".format(pp_var_name))\n            if mean:\n                if dtype == \"f\":\n                    ax.plot(\n                        *_empirical_cdf(posterior_predictive[pp_var_name].values.flatten()),\n                        color=\"C0\",\n                        linestyle=\"--\",\n                        linewidth=linewidth,\n                        label=\"Posterior predictive mean {}\".format(pp_var_name)\n                    )\n                else:\n                    ax.plot(\n                        *_empirical_cdf(posterior_predictive[pp_var_name].values.flatten()),\n                        color=\"C0\",\n                        linestyle=\"--\",\n                        linewidth=linewidth,\n                        drawstyle=\"steps-pre\",\n                        label=\"Posterior predictive mean {}\".format(pp_var_name)\n                    )\n            if var_name != pp_var_name:\n                xlabel = \"{} / {}\".format(var_name, pp_var_name)\n            else:\n                xlabel = var_name\n            ax.set_xlabel(var_name, fontsize=ax_labelsize)\n            ax.set_yticks([0, 0.5, 1])\n        ax.legend(fontsize=xt_labelsize)\n    return axes\n\n\ndef _empirical_cdf(data):\n    \"\"\"Compute empirical cdf of a numpy array.\n\n    Parameters\n    ----------\n    data : np.array\n        1d array\n\n    Returns\n    -------\n    np.array, np.array\n        x and y coordinates for the empirical cdf of the data\n    \"\"\"\n    return np.sort(data), np.linspace(0, 1, len(data))\n", "path": "arviz/plots/ppcplot.py"}], "after_files": [{"content": "\"\"\"Posterior predictive plot.\"\"\"\nimport numpy as np\nfrom .kdeplot import plot_kde, _fast_kde\nfrom .plot_utils import _scale_fig_size, _create_axes_grid, default_grid\n\n\ndef plot_ppc(\n    data, kind=\"density\", alpha=0.2, mean=True, figsize=None, textsize=None, data_pairs=None\n):\n    \"\"\"\n    Plot for Posterior Predictive checks.\n\n    Note that this plot will flatten out any dimensions in the posterior predictive variables.\n\n    Parameters\n    ----------\n    data : Array-like\n        Observed values\n    kind : str\n        Type of plot to display (density or cumulative)\n    alpha : float\n        Opacity of posterior predictive density curves\n    mean : bool\n        Whether or not to plot the mean posterior predictive distribution. Defaults to True\n    figsize : tuple\n        Figure size. If None it will be defined automatically.\n    textsize: float\n        Text size scaling factor for labels, titles and lines. If None it will be autoscaled based\n        on figsize.\n    data_pairs : dict\n        Dictionary containing relations between observed data and posterior predictive data.\n        Dictionary structure:\n            Key = data var_name\n            Value = posterior predictive var_name\n        Example: `data_pairs = {'y' : 'y_hat'}`\n\n    Returns\n    -------\n    axes : matplotlib axes\n\n    Examples\n    --------\n    Plot the observed data KDE overlaid on posterior predictive KDEs.\n\n    .. plot::\n        :context: close-figs\n\n        >>> import arviz as az\n        >>> data = az.load_arviz_data('radon')\n        >>> az.plot_ppc(data)\n\n    Plot the overlay with empirical CDFs.\n\n    .. plot::\n        :context: close-figs\n\n        >>> az.plot_ppc(data, kind='cumulative')\n\n    \"\"\"\n    for group in (\"posterior_predictive\", \"observed_data\"):\n        if not hasattr(data, group):\n            raise TypeError(\n                '`data` argument must have the group \"{group}\" for ppcplot'.format(group=group)\n            )\n\n    if kind.lower() not in (\"density\", \"cumulative\"):\n        raise TypeError(\"`kind` argument must be either `density` or `cumulative`\")\n\n    if data_pairs is None:\n        data_pairs = {}\n\n    observed = data.observed_data\n    posterior_predictive = data.posterior_predictive\n\n    rows, cols = default_grid(len(observed.data_vars))\n\n    (figsize, ax_labelsize, _, xt_labelsize, linewidth, _) = _scale_fig_size(\n        figsize, textsize, rows, cols\n    )\n\n    _, axes = _create_axes_grid(len(observed.data_vars), rows, cols, figsize=figsize)\n\n    for ax, var_name in zip(np.atleast_1d(axes), observed.data_vars):\n        dtype = observed[var_name].dtype.kind\n        if kind == \"density\":\n            if dtype == \"f\":\n                plot_kde(\n                    observed[var_name].values.flatten(),\n                    label=\"Observed {}\".format(var_name),\n                    plot_kwargs={\"color\": \"k\", \"linewidth\": linewidth, \"zorder\": 3},\n                    fill_kwargs={\"alpha\": 0},\n                    ax=ax,\n                )\n            else:\n                vals = observed[var_name].values.flatten()\n                nbins = round(len(vals) ** 0.5)\n                hist, bin_edges = np.histogram(vals, bins=nbins, density=True)\n                hist = np.concatenate((hist[:1], hist))\n                ax.plot(\n                    bin_edges,\n                    hist,\n                    label=\"Observed {}\".format(var_name),\n                    color=\"k\",\n                    linewidth=linewidth,\n                    zorder=3,\n                    drawstyle=\"steps-pre\",\n                )\n            pp_var_name = data_pairs.get(var_name, var_name)\n            # run plot_kde manually with one plot call\n            pp_densities = []\n            for _, chain_vals in posterior_predictive[pp_var_name].groupby(\"chain\"):\n                for _, vals in chain_vals.groupby(\"draw\"):\n                    if dtype == \"f\":\n                        pp_density, lower, upper = _fast_kde(vals)\n                        pp_x = np.linspace(lower, upper, len(pp_density))\n                        pp_densities.extend([pp_x, pp_density])\n                    else:\n                        nbins = round(len(vals) ** 0.5)\n                        hist, bin_edges = np.histogram(vals, bins=nbins, density=True)\n                        hist = np.concatenate((hist[:1], hist))\n                        pp_densities.extend([bin_edges, hist])\n            plot_kwargs = {\"color\": \"C5\", \"alpha\": alpha, \"linewidth\": 0.5 * linewidth}\n            if dtype == \"i\":\n                plot_kwargs[\"drawstyle\"] = \"steps-pre\"\n            ax.plot(*pp_densities, **plot_kwargs)\n            ax.plot([], color=\"C5\", label=\"Posterior predictive {}\".format(pp_var_name))\n            if mean:\n                if dtype == \"f\":\n                    plot_kde(\n                        posterior_predictive[pp_var_name].values.flatten(),\n                        plot_kwargs={\n                            \"color\": \"C0\",\n                            \"linestyle\": \"--\",\n                            \"linewidth\": linewidth,\n                            \"zorder\": 2,\n                        },\n                        label=\"Posterior predictive mean {}\".format(pp_var_name),\n                        ax=ax,\n                    )\n                else:\n                    vals = posterior_predictive[pp_var_name].values.flatten()\n                    nbins = round(len(vals) ** 0.5)\n                    hist, bin_edges = np.histogram(vals, bins=nbins, density=True)\n                    hist = np.concatenate((hist[:1], hist))\n                    ax.plot(\n                        bin_edges,\n                        hist,\n                        color=\"C0\",\n                        linewidth=linewidth,\n                        label=\"Posterior predictive mean {}\".format(pp_var_name),\n                        zorder=2,\n                        linestyle=\"--\",\n                        drawstyle=\"steps-pre\",\n                    )\n            if var_name != pp_var_name:\n                xlabel = \"{} / {}\".format(var_name, pp_var_name)\n            else:\n                xlabel = var_name\n            ax.set_xlabel(xlabel, fontsize=ax_labelsize)\n            ax.tick_params(labelsize=xt_labelsize)\n            ax.set_yticks([])\n\n        elif kind == \"cumulative\":\n            if dtype == \"f\":\n                ax.plot(\n                    *_empirical_cdf(observed[var_name].values.flatten()),\n                    color=\"k\",\n                    linewidth=linewidth,\n                    label=\"Observed {}\".format(var_name),\n                    zorder=3\n                )\n            else:\n                ax.plot(\n                    *_empirical_cdf(observed[var_name].values.flatten()),\n                    color=\"k\",\n                    linewidth=linewidth,\n                    label=\"Observed {}\".format(var_name),\n                    drawstyle=\"steps-pre\",\n                    zorder=3\n                )\n            pp_var_name = data_pairs.get(var_name, var_name)\n            # run plot_kde manually with one plot call\n            pp_densities = []\n            for _, chain_vals in posterior_predictive[pp_var_name].groupby(\"chain\"):\n                for _, vals in chain_vals.groupby(\"draw\"):\n                    pp_x, pp_density = _empirical_cdf(vals)\n                    pp_densities.extend([pp_x, pp_density])\n            if dtype == \"f\":\n                ax.plot(*pp_densities, alpha=alpha, color=\"C5\", linewidth=linewidth)\n            else:\n                ax.plot(\n                    *pp_densities,\n                    alpha=alpha,\n                    color=\"C5\",\n                    drawstyle=\"steps-pre\",\n                    linewidth=linewidth\n                )\n            ax.plot([], color=\"C5\", label=\"Posterior predictive {}\".format(pp_var_name))\n            if mean:\n                if dtype == \"f\":\n                    ax.plot(\n                        *_empirical_cdf(posterior_predictive[pp_var_name].values.flatten()),\n                        color=\"C0\",\n                        linestyle=\"--\",\n                        linewidth=linewidth,\n                        label=\"Posterior predictive mean {}\".format(pp_var_name)\n                    )\n                else:\n                    ax.plot(\n                        *_empirical_cdf(posterior_predictive[pp_var_name].values.flatten()),\n                        color=\"C0\",\n                        linestyle=\"--\",\n                        linewidth=linewidth,\n                        drawstyle=\"steps-pre\",\n                        label=\"Posterior predictive mean {}\".format(pp_var_name)\n                    )\n            if var_name != pp_var_name:\n                xlabel = \"{} / {}\".format(var_name, pp_var_name)\n            else:\n                xlabel = var_name\n            ax.set_xlabel(var_name, fontsize=ax_labelsize)\n            ax.set_yticks([0, 0.5, 1])\n        ax.legend(fontsize=xt_labelsize)\n    return axes\n\n\ndef _empirical_cdf(data):\n    \"\"\"Compute empirical cdf of a numpy array.\n\n    Parameters\n    ----------\n    data : np.array\n        1d array\n\n    Returns\n    -------\n    np.array, np.array\n        x and y coordinates for the empirical cdf of the data\n    \"\"\"\n    return np.sort(data), np.linspace(0, 1, len(data))\n", "path": "arviz/plots/ppcplot.py"}]}