My solution for live stock price plotting:
-
bokeh sever running
-
start page based on MultiPlot class (see below)
-
Plot class (see below)
On the start page the user can add a Plot for each stock by selecting it from a list.
Multiplot class has:
-
self.div = Div(text = “”, width = 1200, height = 0) where all plots are added
-
Dropdown with stock list (to select by the user)
-
Plot list for holding added plots = Plot objects, instantiated with: plot = Plot(params)
-
Add plot method:
rootLayout = curdoc().get_model_by_name(self.plot_container)
listOfSubLayouts = rootLayout.children
listOfSubLayouts.append(plot.get_figure())
-
init method with:
mainLayout = column(row(self.div, name = “Multiple Plots Container”))
curdoc().add_root(mainLayout)
curdoc().add_periodic_callback(self.update, 1000)
session = push_session(curdoc())
session.show()
session.loop_until_closed()
-
update method with:
for iter in self.plots:
self.plots[iter].update(stock_data)
Plot class has:
-
self.plot_main = Figure()
-
source_lines = ColumnDataSource(data_source_dict)
-
self.lines = self.plot_main.line(params, source = self.source_lines)
-
update method with self.source_lines.stream(new_source_data)
What I am getting are two identical plots (see attached image) with a saw pattern. The points (bullets) match the data. The problem is that the points are not being connected with each other with lines but always go to point 0 there between
Any clue what I am doing wrong?



