code
-
-
original
import time import numpy as np from bokeh.plotting import cursession, figure, show, output_server from bokeh.models import GlyphRenderer x = np.linspace(0, 4*np.pi, 200) y = np.sin(x) output_server("simple_stream") p = figure(title="Simple streaming example") p.line(x, y, color="#2222aa", line_width=2) show(p) ds = p.select({"type": GlyphRenderer})[0].data_source while True: oldx = ds.data["x"] newx = np.hstack([oldx, [oldx[-1] + 4*np.pi/200]]) ds.data["x"] = newx ds.data["y"] = np.sin(newx) cursession().store_objects(ds) time.sleep(0.5) -
convert to bokeh 0.11
#! conding utf-8 import time import numpy as np from bokeh.io import curdoc from bokeh.client import push_session from bokeh.models import GlyphRenderer from bokeh.plotting import figure, show x = np.linspace(0, 4*np.pi, 200) y = np.sin(x) p = figure(title="Simple streaming example") p.line(x, y, color="#2222aa", line_width=2) ds = p.select({"type": GlyphRenderer})[0].data_source def update(): oldx = ds.data["x"] newx = np.hstack([oldx, [oldx[-1] + 4*np.pi/200]]) ds.data["x"] = newx ds.data["y"] = np.sin(newx) # run every 5 milliseconds curdoc().add_periodic_callback(update, 5) session = push_session(curdoc(), 'simple-stream') # open the doc in browser session.show() # run forever session.loop_until_closed()
-
class GlyphRenderer(**kwargs)
-
base bokeh.models.renderers.DataRenderer
-
attr
-
data_sourcelocal data source to use when rendering glyph on the plot -
glyphthe glyph to render, in conjunction with supplied data source and ranges -
hover_glyphan optional glyph ofr inspected pointse.g. those that are being hoverd over by a HoverTool -
levelspecifies the level in which to render the glyph -
nonselection_glyphan optional glyph used for explicitly non-selected points -
selection_glyphan optional glyph used for selected points -
x_range_namea particular(named) x-range to use for computing screen locations when rendering glyph on the plotif unset use the default x-range -
y_range_namesee x_range_name
-