Hi, I have an issue with bokeh and updating the colorbar object. I am trying to update my color bar according to new data plotted via a dropdown callback. The data is getting updated, but the color bar remains scaled to the original data. I have searched the color bar related issues and can’t find a solution. I get this error when I try to just assign a new ColorBar object to the Figure: "AttributeError(“unexpected attribute ‘color_bar’ to Figure.”
Here are the lines I’m using to update on the dropdown selection:
def update_plot(attrname, old, new):
# set variables for new data
data_set = data_select.value
plot_data_name = data_sets.get(data_set)
data = dataframe[plot_data_name]
data_min = data.min()
data_max = data.max()
# create new colors according to changed data set
colors = set_colors(dataframe, data_set)
dataframe['colors'] = colors
new_source = ColumnDataSource(dataframe)
# update plot
plot.title.text = data_set
source.data.update(new_source.data)
color_mapper = LinearColorMapper(palette=Viridis256, low=data_min, high=data_max)
color_bar = ColorBar(color_mapper=color_mapper, \
label_standoff=12, border_line_color=None, location=(0,0))
plot.add_layout(color_bar, 'right')
I guess that I am just trying to overwrite the old ColorBar, but it’s not working, and I am kinda stuck right now. Am I missing some simple way to do this?
Thanks,
Charles

