How do I update the bokeh colorbar with a new colormap?

The general, always-applicable best-practice rule with Bokeh is: always make the smallest change possible . In this context (and usually) that means updating simple properties of existing objects (i.e. the palette property of the existing color mapper), rather than trying to replace entire bokeh object.

def update():
    img.glyph.color_mapper.palette = cbar.value
    color_bar.color_mapper.palette = cbar.value
2 Likes