Repository: arviz-devs/arviz

Issue:
Add example to az.plot_hdi that shows how to plot hdi from InferenceData posterior or posterior predictive
## Tell us about it
The `az.plot_hdi` docs only show how to plot the hdi from synthetic data. What would be nice is if it also shows users how to plot the hdi from an `az.InferenceData` as thats the standard data representation most people will be working with.

![image](https://user-images.githubusercontent.com/7213793/103111300-5d0cdb00-4600-11eb-973e-3c710b4a63cc.png)

## Thoughts on implementation
Use one of the precomputed datasets that has a posterior predictive group and create a plot.

Here's an example of loading a dataset with posterior predictive group
https://arviz-devs.github.io/arviz/api/generated/arviz.plot_ppc.html

Here's an (unrelated) example where PyMC3 generates a trace and posterior predictive group and its used with `az.plot_hdi`

```
with pm.Model() as model_linear:
    β = pm.Normal('β', sd=10, shape=2)

    μ = pm.Deterministic('μ', pm.math.dot(babies[["Intercept", "Month"]], β))
    ϵ = pm.HalfNormal('ϵ', sd=10)

    length = pm.Normal('length', mu=μ, sd=ϵ, observed=babies.Length)

    linear_trace = pm.sample(2000, tune=4000)
    linear_ppc = pm.sample_posterior_predictive(inf_data_linear)
    inf_data_linear = az.from_pymc3(trace=linear_trace, posterior_predictive= linear_ppc)

fig, ax = plt.subplots()

ax.set_ylabel("Length")
ax.set_xlabel("Month");

μ_m = inf_data_linear.posterior["μ"].values.reshape(-1, babies.Length.shape[0]).mean(axis=0)

ax.plot(babies.Month, μ_m, c='C4')
az.plot_hdi(babies.Month, inf_data_linear.posterior_predictive["length"], hdi_prob=.94, ax=ax)

ax.plot(babies.Month, babies.Length, 'C0.', alpha=0.1)

plt.savefig('img/Baby_Length_Linear_Fit.png', dpi=300)

```
![image](https://user-images.githubusercontent.com/7213793/103111469-39e32b00-4602-11eb-8ab5-a9727900ed6e.png)
![image](https://user-images.githubusercontent.com/7213793/103111474-45ceed00-4602-11eb-8ec2-83c0fd7ca9bd.png)




Discussion:
can i work on this issue
Cool, what is your idea?
Using precomputed data set 
We can add more examples available from `load_arviz_data` if necessary, but only documentation of converter methods should have inferenc-library-specific code.
This issue looks inactive, can I take it @OriolAbril ?
yes, assigning it to you

Resolving patch:
diff --git a/arviz/plots/hdiplot.py b/arviz/plots/hdiplot.py
--- a/arviz/plots/hdiplot.py
+++ b/arviz/plots/hdiplot.py
@@ -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 = {}


Test patch: