Last modified: 18 December 2023

Starting the bokeh backendĀ [New]

[New] New in CIAO 4.16 is support for plotting with the Bokeh backend rather than Matplotlib. This is useful for people who use Jupyter notebooks for their analysis, as bokeh requires a webserver to create plots for interactive analysis.

After installing bokeh with

% pip install bokeh

and, for Jupyter lab users,

% pip install jupyter_bokeh

then the bokeh backend can be selected using the set_plot_backend call. Note that Bokeh works differently to Matlpotlib which means that you will need to explicitly display the plot at the end of each Jupyter cell.

So, with the commands

from sherpa.astro import ui
from bokeh.plotting import show
import sherpa.plot

then the Bokeh backend can be selected with


The notebook support must be started before a plot is created with:

from import output_notebook

After this, plots can be created with the normal Sherpa plot commands like plot_data, but the show command shown below is needed to display the visualization:

ui.load_arrays(1, [1, 2, 3], [10, 2, 20])

It is suggested that you use a simple helper function like the display function below:

def display():