I would like to refresh a bokeh document so I can replace old plots with new ones. However, right now I just get the new plots appended to the document so the old ones don't go away.
#myfile.py
from bokeh.plotting import curdoc, figure
doc = curdoc()
p1 = figure(width=1500, height=230, active_scroll="wheel_zoom")
doc.add_root(p1)
doc.clear()
p2 = figure(width=1500, height=500, active_scroll="wheel_zoom")
doc.add_root(p2)
This results in the second plot being displayed after the first plot, though the expected behavior I am looking for is the second plot replacing the first plot. How can I resolve this? I am running this on a bokeh server via bokeh serve --show myfile.py