# Plotting with Bokeh#

Arviz has the option to use Bokeh as backend which offers interactive plots. Although most of the functions in the plot module work seamlessly with any backend, some advanced plots may require the use of backend specific features. In this guide, advanced plotting with Bokeh will be covered.

This page can be downloaded as a Jupyter notebook.

import arviz as az
import matplotlib.pyplot as plt
import numpy as np

az.style.use("arviz-darkgrid")

# Confgure Bokeh as backend
az.rcParams["plot.backend"] = "bokeh"
az.output_notebook()


Note

To display the plots as output in a Jupyter notebook, it’s required to call the function arviz.output_notebook() beforehand.

## Customizing plots#

### Using backend_kwargs#

The backend_kwargs argument can be very useful for some specific configuration. That is parameters available in bokeh.plotting.figure.Figure. As the options available depends on the backend, this parameter is not as flexible as creating custom axes.

As an example, the following code changes the color background and the plot width.

# load data

az.plot_posterior(
data,
var_names=["g"],
backend_kwargs={"width": 350,
"background_fill_color": "#d3d0e3"});


### The parameter show#

The parameter show is used to control whether the plot is displayed or not. This behavior can be useful when a plot will be displayed in a grid as the example in the following section.

### Defining custom axes#

The ax argument of any plot function allows to use created axes manually. In the example, this parameter allows to arrange 2 different plots in a grid, set limit to the x axis and share the axes’ ranges between the two plots.

from bokeh.io import show
from bokeh.layouts import row
from bokeh.plotting import figure