(gallery_forest_pp_obs)=

# Posterior predictive forest and observations

Overlay of forest plot for the posterior predictive samples and the actual observations



::::::{tab-set}
:class: full-width
:sync-group: backend

:::::{tab-item} Matplotlib
:sync: matplotlib

![Matplotlib version of plot_forest_pp_obs](_images/plot_forest_pp_obs.png)

:::::

:::::{tab-item} Bokeh
:sync: bokeh

```{bokeh-plot}
:source-position: none

from bokeh.plotting import show

from arviz_base import load_arviz_data

import arviz_plots as azp

azp.style.use("arviz-variat")

idata = load_arviz_data("non_centered_eight")
pc = azp.plot_forest(
idata,
group="posterior_predictive",
combined=True,
labels=["obs_dim_0"],
backend="bokeh",  # change to preferred backend
)

pc.map(
azp.visuals.scatter_x,
"observations",
data=idata.observed_data.ds,
coords={"column": "forest"},
color="C0",
)

pc.map(
azp.visuals.labelled_x,
"xlabel",
coords={"column": "forest"},
text="Observations",
ignore_aes="y",
)


# for some reason the bokeh plot extension needs explicit use of show
show(pc.viz["figure"].item() if pc.viz["figure"].item() is not None else pc.viz["plot"].item())
```

Link to this page with the [bokeh tab selected](https://arviz-plots.readthedocs.io/en/latest//gallery/plot_forest_pp_obs.html?backend=bokeh#synchronised-tabs)
:::::

:::::{tab-item} Plotly
:sync: plotly

```{jupyter-execute}
:hide-code:

from arviz_base import load_arviz_data

import arviz_plots as azp

azp.style.use("arviz-variat")

idata = load_arviz_data("non_centered_eight")
pc = azp.plot_forest(
idata,
group="posterior_predictive",
combined=True,
labels=["obs_dim_0"],
backend="plotly",  # change to preferred backend
)

pc.map(
azp.visuals.scatter_x,
"observations",
data=idata.observed_data.ds,
coords={"column": "forest"},
color="C0",
)

pc.map(
azp.visuals.labelled_x,
"xlabel",
coords={"column": "forest"},
text="Observations",
ignore_aes="y",
)
pc.show()
```

Link to this page with the [plotly tab selected](https://arviz-plots.readthedocs.io/en/latest//gallery/plot_forest_pp_obs.html?backend=plotly#synchronised-tabs)
:::::
::::::

```{literalinclude} _scripts/plot_forest_pp_obs.py
:emphasize-lines: 13
```



:::{seealso}
API Documentation: {func}`~arviz_plots.plot_forest`
:::



## Other examples with `plot_forest`

```{eval-rst}
.. minigallery:: plot_forest
```


:::{div} example-plot-download
{download}`Download Python Source Code: plot_forest_pp_obs.py<_scripts/plot_forest_pp_obs.py>`
:::
