Hi,
I’m implementing a realtime streaming plot with bokeh.
The code below can live update the plot, but the plot stop to update after around 300 steps.
I can not figure out what’s the problem there.
BTW, i’m using the latest version of bokeh on Python 2.7.3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np
from bokeh.client import push_session
from bokeh.plotting import figure, curdoc, reset_output
from bokeh.models import Range1d
from bokeh.io import save
x = np.array([])
y = np.array([])
p1 = figure(plot_width=1000, plot_height=200, title="bleu")
r2 = p1.line(x, y, line_width=1)
r3 = p1.scatter(x, y, size=5)
p2 = figure(plot_width=1000, plot_height=200, title="reward")
r4 = p2.line(x, y, line_width=1)
r5 = p2.scatter(x, y, size=5)
# open a session to keep our local document in sync with server
doc = curdoc()
session = push_session(doc, session_id="test1", url="http://xxx.com:5006")
session.document.add_root(p1)
session.document.add_root(p2)
import time
for d in range(1000):
# updating a single column of the the *same length* is OK
rand_num = np.random.rand()*10
rand_num2 = np.random.rand()*10
r2.data_source.stream({"x":[d], "y":[rand_num2]})
r3.data_source.stream({"x":[d], "y":[rand_num2]})
r4.data_source.stream({"x":[d], "y":[rand_num2]})
r5.data_source.stream({"x":[d], "y":[rand_num2]})
p1.x_range = Range1d(0, d + 100)
p2.x_range = Range1d(0, d + 100)
time.sleep(0.1)
``
