python - Streaming two line graphs using bokeh -


i create visualization there 2 line graphs updated 1 new point per line graph per second. result this.

i have read bokeh , found out can used in visualizing streams of data in real time. don't know how code in yet.

i appreciate if can show me how task can done using bokeh. thanks!

for bokeh-0.11.1:

basically, need run python app in bokeh server. can connect server , view graph in realtime.

first, write program. use code example:

# myplot.py bokeh.plotting import figure, curdoc bokeh.driving import linear import random  p = figure(plot_width=400, plot_height=400) r1 = p.line([], [], color="firebrick", line_width=2) r2 = p.line([], [], color="navy", line_width=2)  ds1 = r1.data_source ds2 = r2.data_source  @linear() def update(step):     ds1.data['x'].append(step)     ds1.data['y'].append(random.randint(0,100))     ds2.data['x'].append(step)     ds2.data['y'].append(random.randint(0,100))       ds1.trigger('data', ds1.data, ds1.data)     ds2.trigger('data', ds2.data, ds2.data)  curdoc().add_root(p)  # add periodic callback run every 500 milliseconds curdoc().add_periodic_callback(update, 500) 

then run server command line, program:

c:\>bokeh serve --show myplot.py 

this open browser realtime graph.

for details see bokeh server documentation.