[英]How to change color mapper in Bokeh image plot
I have a Bokeh image plot that I want to change interactively, eg: 我有一个要交互更改的散景图像图,例如:
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)
I can update the range in the colour map by using: 我可以使用以下方法更新颜色图中的范围:
cm = p.select_one(LinearColorMapper)
cm.update(low=new_data.min(), high=new_data.max())
push_notebook()
However, I would like to interactively be able to change to a different type of colour map, eg from LinearColorMapper
to LogColorMapper
. 但是,我希望能够交互式地更改为其他类型的颜色图,例如,从LinearColorMapper
到LogColorMapper
。 The above only lets me access the LinearColorMapper
object, not replace it. 上面的内容只允许我访问LinearColorMapper
对象,而不是替换它。 Is there a way to do this interactively without having to call image
again? 有没有一种方法可以交互式地执行此操作而不必再次调用image
?
Found it, this is in the glyph
object of the image
instance. 找到它,它在image
实例的glyph
对象中。 One can just replace it with another ColorMapper
, eg: 可以用另一个ColorMapper
替换它,例如:
img.glyph.color_mapper = LogColorMapper(palette="Viridis256",
low=new_data.min(),
high=new_data.max())
push_notebook()
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.