I have a plot and a dropdown menu widget. According to the choice from the menu, a different range will be configured for the y axis.
The code looks something like this:
plt = figure(plot_width=1500, plot_height=500,
x_axis_type=“datetime”,
tools=[‘xzoom_in’, ‘xzoom_out’, ‘xpan’, ‘reset’])
plt.y_range = Range1d(0, 1)
select_item = Select(title = ‘Select an item’,
value = data_src[0],
options = list(data_src))
def update_src(item):
feature_list = read_data_for_un(item)
plt.y_range.start = -0.3
plt.y_range.end = len(feature_list) - 0.8
select_item.on_change(‘value’, lambda att, old, new: update_src(new))
Draw the initial graph
update_src(data_src[0])
``
By running the above code, I discover that the initial range of y axis is determined by update_src(data_src[0]) in the above code snippet.
Now if I select an item, say data_src[1], the range of y axis is adjusted acoording to data set of the selected item data_src[1].
I zoom in the graph and press Bokeh’s default reset tool while I am still in data_src[1], then the range of the y axis goes back to when update_src(data_src[0]) was selected, while my intention is to restore the range for data_src[1]
Is there some way to override the behavior of reset tool or is there any way to make it behave as I intend?
My question seems similar to the question in the following post but I still cannot figure out how to do it:
https://stackoverflow.com/questions/39992566/how-to-make-figure-changes-survive-the-reset-button-in-bokeh