Hi,
I have a simple code which plots on the browser (attached below). I have two questions. The first is how do I refresh this plot? That is if I rerun the python code that I use to plot the graph is there a way I can automatically delete the old plot on the browser? Right now it just creates a second identical plot on the browser.
The second question is, I want to introduce a second plot to appear on the browser mid way through the program (see the last 4 commented lines on the code below). This does not produce a plot on the browser. I know that IPython.display.clear_output(True) will not work on the browser (its there because it works on the python notebook when outputting to the notebook). Is there any function which works the same way for the browser?
Thanks,
Charith
########## CODE BLOCK 1 #############
def make_plot(x,y):
source = ColumnDataSource(data=dict(x=x, y=y))
p = figure(tools=“save, resize”,
background_fill_color="#E8DDCB", height=200, width=200)
p.circle(x=‘x’, y=‘y’, size=20, color=“navy”, alpha=0.5, source=source)
return p, source
from bokeh.models import ColumnDataSource, Range1d
from bokeh.plotting import figure, curdoc
from bokeh.layouts import Row
from bokeh.io import push_notebook
from bokeh.plotting import show, figure, curdoc, output_server
from bokeh.client import push_session, pull_session
import IPython.display
session = push_session(curdoc())
x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]
p1, source = make_plot(x,y)
session.show(Row(p1))
############### CODE BLOCK 2 ###################
x = [4, 2, 3, 3, 6]
y = [3, 7, 1, 3, 4]
p2, source2 = make_plot(x,y)