(gallery_dist_kde)=

# Posterior KDEs

KDE plot of the variable `mu` from the centered eight model. The `sample_dims` parameter is
used to restrict the KDE computation along the `draw` dimension only.


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

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

![Matplotlib version of plot_dist_kde](_images/plot_dist_kde.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")

data = load_arviz_data("centered_eight")
pc = azp.plot_dist(
data,
kind="kde",
var_names=["mu"],
sample_dims=["draw"],
backend="bokeh"  # change to preferred backend
)
pc.add_title("KDE of μ by Chain (Centered Eight)")


# 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_dist_kde.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")

data = load_arviz_data("centered_eight")
pc = azp.plot_dist(
data,
kind="kde",
var_names=["mu"],
sample_dims=["draw"],
backend="plotly"  # change to preferred backend
)
pc.add_title("KDE of μ by Chain (Centered Eight)")
pc.show()
```

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

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



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

EABM chapter on [Visualization of Random Variables with ArviZ](https://arviz-devs.github.io/EABM/Chapters/Distributions.html#distributions-in-arviz)
:::



## Other examples with `plot_dist`

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


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