Streaming bokeh

Download this notebook from GitHub (right-click to download).

import numpy as np
import panel as pn

from bokeh.plotting import figure
from bokeh.models import ColumnDataSource

p = figure(sizing_mode='stretch_width', title='Bokeh streaming example')

xs = np.arange(1000)
ys = np.random.randn(1000).cumsum()
x, y = xs[-1], ys[-1]

cds = ColumnDataSource(data={'x': xs, 'y': ys})

p.line('x', 'y', source=cds)

bk_pane = pn.pane.Bokeh(p)
def stream():
    global x, y
    x += 1
    y += np.random.randn(){'x': [x], 'y': [y]}) # Only needed when running in notebook context
pn.state.add_periodic_callback(stream, 100)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).