I am learning to use Bokeh for an interactive plotting tool. The issue I have is similar to the case in a Mandelbrot chart, when zooming into it, the new area is redraw. This requires BokehJS to send the new X and Y ranges back the Bokeh backend to regenerate the data and send it back to BokehJS to redraw. How can this be done in Bokeh?
Asked
Active
Viewed 506 times
2
-
1I too would like to know how to force Bokeh to redraw. Did you find an answer? – Brian Apr 14 '15 at 19:55
-
I'm also dealing with the similar problem. I can't make and image redraw with source.trigger('change') after changing the image data inside a CustomJS callback function. It works in an ipython notebook using push_notebook() from bokeh.io. But I want to make it work in a static document. – Pablo Reyes Feb 18 '16 at 15:29
1 Answers
2
I am the project lead for Bokeh, but I am actually going to recommend that for this you turn to Holoviews which is built on top of Bokeh. To do this in pure Bokeh is a bit low level and tedious, because Bokeh does not expose a single unified range update, only low level individual range start/end updates. Using Bokeh directly would require alot of code to throttle and coalesce events to avoid lots of unnecessary re-computation. Holoviews, being at a higher level, has already done all this. Then even have an interactive Mandlebrot example ready to run (like any standard Bokeh app). The code (minus the fractal compute parts) looks like this:
def get_fractal(x_range, y_range):
(x0, x1), (y0, y1) = x_range, y_range
image = np.zeros((600, 600), dtype=np.uint8)
return hv.Image(create_fractal(x0, x1, -y1, -y0, image, 200),
bounds=(x0, y0, x1, y1))
# Define stream linked to axis XY-range
range_stream = RangeXY(x_range=(-1., 1.), y_range=(-1., 1.))
# Create DynamicMap to compute fractal per zoom range and
# adjoin a logarithmic histogram
dmap = hv.DynamicMap(get_fractal, label='Manderbrot Explorer',
streams=[range_stream]).hist(log=True)
# Define styling options
options = hv.Store.options('bokeh')
options.Image = {
'style': Options(cmap='fire'),
'plot' : Options(logz=True, height=600, width=600,
xaxis=None, yaxis=None)
}
options.Histogram = {
'norm': Options(framewise=True),
'plot': Options(logy=True, width=200)
}
doc = BokehRenderer.server_doc(dmap)
doc.title = 'Mandelbrot Explorer'

bigreddot
- 33,642
- 5
- 69
- 122