Hi,
I’m trying to build an interactive plot that changes an image plot based on values on a slider, similar to what the example notebook Jupyter Interactors.ipynb does for a line plot. I’m using jupyter notebook, and running the example notebook works fine.
For the image plot, I’ve done the following:
color_mapper = LinearColorMapper(palette=“Viridis256”, low=0, high=200)
p = figure(plot_width=400, plot_height=400, x_range=(0, 400), y_range=(0, 00))
img = p.image(image=[my_array], x=[0], y=[0], dw=[400], dh=[400],
color_mapper=color_mapper)
show(p, notebook_handle=True)
Now, if I try to modify the image data with the following:
img.data_source.data[‘image’] = new_array
push_notebook()
This new_array has the same shape as the original my_array. This produces no change in the figure and gives the following error:
/Users/yyy/miniconda/lib/python3.6/site-packages/bokeh/models/sources.py:110: BokehUserWarning: ColumnDataSource's columns must be of the same length. Current lengths: ('dh', 1), ('dw', 1), ('image', 2), ('x', 1), ('y', 1)
"Current lengths: %s" % ", ".join(sorted(str((k, len(v))) for k, v in data.items())), BokehUserWarning))
I get the same warning and lack of change if I try to change any other parameters of the data source (e.g. x, y, dw, dh).
Is this a bug, or am I doing something wrong? How can I update an image plot?
Thanks,
Tiago