(gallery_add_reference_lines)=

# Add Lines

Draw lines on plots to highlight specific thresholds, targets, or important values.



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

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

![Matplotlib version of add_reference_lines](_images/add_reference_lines.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")
ref_ds = data.posterior.dataset.quantile([0.5, 0.1, 0.9], dim=["chain", "draw"])
pc = azp.plot_dist(
data,
kind="ecdf",
backend="bokeh",   # change to preferred backend
)
pc = azp.add_lines(
pc,
values=ref_ds,
ref_dim="quantile",
aes_by_visuals={"ref_line": ["color"]},
color=["black", "gray", "gray"]
)


# 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/add_reference_lines.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")
ref_ds = data.posterior.dataset.quantile([0.5, 0.1, 0.9], dim=["chain", "draw"])
pc = azp.plot_dist(
data,
kind="ecdf",
backend="plotly",   # change to preferred backend
)
pc = azp.add_lines(
pc,
values=ref_ds,
ref_dim="quantile",
aes_by_visuals={"ref_line": ["color"]},
color=["black", "gray", "gray"]
)
pc.show()
```

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

```{literalinclude} _scripts/add_reference_lines.py
:emphasize-lines: 12
```



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



## Other examples with `plot_dist`

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


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