我有一个Bokeh图像图,我想交互更改,例如:
color_mapper = LinearColorMapper(palette="Viridis256", low=tmp.min(), high=tmp.max())
p = figure(plot_width=tmp.shape[0], plot_height=tmp.shape[1],
x_range=(0, tmp.shape[0]), y_range=(0, tmp.shape[1]))
img = p.image(image=[tmp], x=[0], y=[0], dw=[tmp.shape[0]],
dh=[tmp.shape[1]], color_mapper=color_mapper)
我可以使用更新彩色地图中的范围
cm = p.select_one(LinearColorMapper)
cm.update(low=new_data.min(), high=new_data.max())
push_notebook()
然而,我希望能够以交互方式更改为不同类型的颜色图,例如从LinearColorMapper
更改为LogColorMapper
。上面的内容只允许我访问LinearColorMapper
对象,而不是替换它。有没有一种方法可以在不必再次调用image
的情况下以交互方式进行访问?
找到它,它在image
实例的glyph
对象中。可以用另一个ColorMapper
替换它,例如:
img.glyph.color_mapper = LogColorMapper(palette="Viridis256",
low=new_data.min(),
high=new_data.max())
push_notebook()