Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added example to plot_hdi using Inference data #1615

Merged
merged 9 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Added "Label guide" page and API section for `arviz.labels` module ([1201](https://github.com/arviz-devs/arviz/pull/1201) and [1635](https://github.com/arviz-devs/arviz/pull/1635))
* Add "Installation guide" page to the documentation ([1551](https://github.com/arviz-devs/arviz/pull/1551))
* Improve documentation on experimental `SamplingWrapper` classes ([1582](https://github.com/arviz-devs/arviz/pull/1582))
* Added example to `plot_hdi` using Inference Data ([1615](https://github.com/arviz-devs/arviz/pull/1615))

## v0.11.2 (2021 Feb 21)
### New features
Expand Down
13 changes: 13 additions & 0 deletions arviz/plots/hdiplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,19 @@ def plot_hdi(
>>> ax = az.plot_hdi(x_data, hdi_data=hdi_data[0], color="r", fill_kwargs={"alpha": .2})
>>> az.plot_hdi(x_data, hdi_data=hdi_data[1], color="k", ax=ax, fill_kwargs={"alpha": .2})

``plot_hdi`` can also be used with Inference Data objects. Here we use the posterior predictive
to plot the HDI interval.

.. plot::
:context: close-figs

>>> X = np.random.normal(0,1,100)
>>> Y = np.random.normal(2 + X * 0.5, 0.5, (10,100))
>>> idata = az.from_dict(posterior={"y": Y}, constant_data={"x":X})
>>> x_data = idata.constant_data.x
>>> y_data = idata.posterior.y
>>> az.plot_hdi(x_data, y_data)

"""
if hdi_kwargs is None:
hdi_kwargs = {}
Expand Down