Bokeh dashboards

How to deploy a bokeh dashboard.

What is Bokeh

Bokeh is a visualization library and a dashboard framework that allows fine-grained control over the construction of interactive visualizations. Work with Bokeh in Jupyter and when a visualization is ready - deploy it in Saturn.

Set up

To create a basic bokeh example use the following script at project/

import numpy as np

from import curdoc
from bokeh.layouts import column, row
from bokeh.models import ColumnDataSource, Slider, TextInput
from bokeh.plotting import figure

# Set up data
N = 200
x = np.linspace(0, 4*np.pi, N)
y = np.sin(x)
source = ColumnDataSource(data=dict(x=x, y=y))

# Set up plot
plot = figure(plot_height=400, plot_width=400, title="my sine wave",
              x_range=[0, 4*np.pi], y_range=[-2.5, 2.5])

plot.line('x', 'y', source=source, line_width=3, line_alpha=0.6)

# Set up widgets
text = TextInput(title="title", value='my sine wave')
offset = Slider(title="offset", value=0.0, start=-5.0, end=5.0, step=0.1)
amplitude = Slider(title="amplitude", value=1.0, start=-5.0, end=5.0, step=0.1)
phase = Slider(title="phase", value=0.0, start=0.0, end=2*np.pi)
freq = Slider(title="frequency", value=1.0, start=0.1, end=5.1, step=0.1)

# Set up callbacks
def update_title(attrname, old, new):
    plot.title.text = text.value

text.on_change('value', update_title)

def update_data(attrname, old, new):

    # Get the current slider values
    a = amplitude.value
    b = offset.value
    w = phase.value
    k = freq.value

    # Generate the new curve
    x = np.linspace(0, 4*np.pi, N)
    y = a*np.sin(k*x + w) + b = dict(x=x, y=y)

for w in [offset, amplitude, phase, freq]:
    w.on_change('value', update_data)

# Set up layouts and add to document
inputs = column(text, offset, amplitude, phase, freq)

curdoc().add_root(row(inputs, plot, width=800))
curdoc().title = "Sliders"

Or you can choose one of the more interesting dashboards from Bokeh Gallery.


After you’re happy with this, it’s very easy to enable a production deployment. For a production deployment, we need to expose the proper port and allow access.

From the Deployments page in your Saturn dashboard choose the project and use the command:

python -m bokeh serve --port=8000 --address="" --allow-websocket-origin="*"

Click Create. The new Deployment will show on the top of the page:

Initially, the status will be Stopped. Click play to start it.