[The following problem is accidentally put into the Development thread. Sorry for confusing. This is a problem on how to use bokeh correctly]
So please ignoring the logic of the code, but every time the update callback update_plot is called, the plot automatically zoom, and I have no idea why it does this. If I navigate to a different url and click back to the bokeh rendering page, the auto zooming effect is gone. This problem will not arise if I use glyph and Line class. It only arise when there is plot.line() in the callback function. Please help me how to get rid of the auto zooming which is pretty annoying
import numpy as np
import pandas as pd
from bokeh.models import ColumnDataSource, Select, CustomJS, TextInput, Legend, LegendItem
from bokeh.plotting import figure
from bokeh.layouts import row
from bokeh.io import curdoc,show
from bokeh.models.glyphs import Line
doc = curdoc()
table = [[1,2,3,4,1],[2,3,4,5,2],[3,4,5,6,3],[4,5,6,7,4]]
df = pd.DataFrame(table, columns=['a','b','c','d','e'])
colors = ["navy", "firebrick", "red", "darkorchid", "hotpink", "black", "pink"]
next_group = 1
source = ColumnDataSource(data = {'x':[], 'y':[]})
plot = figure(width=400, plot_height=300, title=None, tools='pan')
# plot.legend.location = "top_left"
# plot.legend.click_policy="mute"
# menu = Select(options=['ab', 'ac', 'bc','abc','abd','abcd'],
# value='ab', title='Type')
text_input = TextInput(value="ab", title="Label:")
legends = []
def update_plot(attrname, old, new):
# choice = menu.value
global next_group, legends
source1 = ColumnDataSource(data = {'x':[], 'y':[]})
choice = text_input.value
n = len(df['e'])
cl = [char for char in choice]
source1.data['x'] = df['e'].tolist() * len(cl)
source1.data['y'] = [x for e in cl for x in df[e].tolist()]
plot.line(x='x', y= 'y', source = source1, legend_label = choice, line_width=2, color=colors[next_group], muted_alpha = 0.1)
plot.legend.location = "top_left"
plot.legend.click_policy="mute"
next_group += 1
text_input.on_change('value', update_plot)
doc.add_root(row(plot, text_input))