#!/usr/bin/env python # coding: utf-8 # # Bokeh.js streaming # # Bokeh.js supports streaming data to a notebook. # The basics are: # # 1. modify a bokeh data source # 2. call `data_source.push_notebook()` to update the display # In[1]: # from http://stackoverflow.com/questions/28051780/memory-overflows-when-streaming-data-using-bokeh-push-notebook from bokeh.plotting import figure, show, output_notebook import numpy as np output_notebook() x = np.linspace(0., 1000., 1000) p = figure() p.line(x = x, y = np.sin(x), name = 'y') def update(): renderer = p.select(dict(name='y')) # modify the data in the plot: ds = renderer[0].data_source ds.data['y'] = np.sin(a * x) # push_notebook sends updates to the browser: ds.push_notebook() show(p) a = 1. for i in range(50): update() a *= 1.1 # In[ ]: