
I’m trying to update a plot using widgets with bokeh. My understanding is that bokeh’s widgets either work only with javascript updates or using the bokeh server. For those reasons I tried using ipywidgets and they somewhat work but a new plot is generated every time instead of updating the original plot. How do I achieve that?
Here’s how I tried doing it:
import bokeh.plotting as bkpl
import bokeh.io as bki
import ipywidgets as widgets
from IPython.display import display as idisplay
bki.output_notebook()
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
p = bkpl.figure(title="My chart", x_axis_label='x', y_axis_label='y')
p.line(x, y, legend_label="Some line", line_width=2)
def callback(evt):
bkpl.show(p)
w = widgets.Button(description='Replot')
w.on_click(callback)
display(w)
bkpl.show(p)


