from tornado.ioloop import IOLoop
import numpy as np
from bokeh.application.handlers import FunctionHandler
from bokeh.application import Application
from bokeh.plotting import figure
from bokeh.server.server import Server
from bokeh.models.layouts import VBox
io_loop = IOLoop.current()
layout = VBox()
def modify_doc(doc):
doc.add_root(layout)
doc.add_periodic_callback(add_plot, 3000)
def add_plot():
print("add plot")
x = np.linspace(0, 4 * np.pi, 1000)
y = np.sin(x)
plot2 = figure(y_range=(-1.2, 1.2), plot_width=300, plot_height=300)
plot2.line(x, y, line_width=2, legend="x")
layout.children.append(plot2)
bokeh_app = Application(FunctionHandler(modify_doc))
server = Server({'/': bokeh_app}, io_loop=io_loop)
server.start()
if __name__ == '__main__':
print('Opening Bokeh application on http://localhost:5006/')
io_loop.add_callback(server.show, "/")
io_loop.start()
@mattpap not sure if this is covered by other issues but I am making a new one specifically because it is a regression. This code works in
0.12.5and0.12.4(plots are added below) but does not work in master (plots stack on top of each other)