Bokeh plot auto zooming problem

It also does not zoom like shown in the gif for me.

For updating multiple lines I would suggest the cds.stream and multi_line instead of line.
With stream you can keep data that was used before. You can add a rollover if you have a maximum of lines to be plotted in the picture.

import numpy as np
import pandas as pd

from bokeh.models import ColumnDataSource, TextInput
from bokeh.plotting import figure
from bokeh.layouts import row
from bokeh.io import curdoc,show

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

source1 = ColumnDataSource(data = {'x':[], 'y':[], 'label':[], 'colors':[]})
plot = figure(width=400, plot_height=300, title=None, tools='pan')

text_input = TextInput(value="ab", title="Label:")


def update_plot(attrname, old, new):
    global next_group

    choice =  text_input.value
    n = len(df['e'])
    cl = [char for char in choice]

    # create a new dict to set up the new source wihtout getting "columns must be of same length" warnings
    new_data = {'x': [df['e'].tolist() * len(cl)], 'y': [[x for e in cl for x in df[e].tolist()]], 'label': [choice], 'colors': [colors[next_group]]}

    # total update 
    #source1.data = new_data

    # use stream for continious updates
    source1.stream(new_data)

    next_group += 1

#plot.line(x='x', y= 'y', source = source1, legend_label = 'label', line_width=2, color=colors[next_group], muted_alpha = 0.1)
plot.multi_line(xs='x', ys= 'y', source = source1, legend = 'label', line_width=2, color='colors', muted_alpha = 0.1)
plot.legend.location = "top_left"
plot.legend.click_policy="mute"


text_input.on_change('value', update_plot)

doc.add_root(row(plot, text_input))

The only thing left to do is the label update, unfortunately this does not seem to work via source :confused: