I have this code and I can update the time-series graph successfully but I am looking for a way to update the bar chart. Is there a way of doing that?
import numpy as np
np.random.seed(1)
from bokeh.layouts import row, column, gridplot
from bokeh.models import ColumnDataSource, Slider, Select
from bokeh.plotting import curdoc, figure
from bokeh.driving import count
from bokeh.models.glyphs import HBar
source = ColumnDataSource(dict(
time=[], average=[], algo_name=[]
))
p2 = figure(plot_height=100, y_axis_location="right")
p2.line(x='time', y='average', color='red', source=source)
p3 = figure(plot_height=100, y_axis_location="right")
p3.hbar(y='algo_name', height=0.5, left=0, right='average', color="#CAB2D6", source=source, fill_alpha=0.3)
def _create_prices(t):
mean = 0
std = 0.04
average = np.asarray(np.random.lognormal(mean, std, 1))
return average[0]
@count()
def update(t):
mean = 0
std = 0.04
average = np.asarray(np.random.lognormal(mean, std, 1))
algo_name = 1
new_data = dict(
time=[t],
average=[average],
algo_name=[algo_name]
)
source.stream(new_data, 100)
series = column(p2, p3)
curdoc().add_root(series)
curdoc().add_periodic_callback(update, 1000)
curdoc().title = "OHLC"