我想使用全息视图显示散射图并每10秒更新一次图。因此我写了一个函数“BokehDisplay”来绘制散射图而不更新,然后我添加了另一个函数“DynamicDisplay”来每10秒更新一次散射图。但是,散射图仅在我运行第一个函数时出现,而不是在我运行第二个函数时出现。任何提示都将受到高度赞赏!谢谢!
from datetime import datetime
import holoviews as hv
import numpy as np
import time
hv.extension('bokeh')
def BokehDisplay():
x, y = [], []
with open("evening_commute_time.txt", "r") as f:
for line in f:
x.append(line[:19])
y.append(int(line[27:29]))
x_time = np.array(x, dtype = np.datetime64)
scatter = hv.Scatter((x_time,y), kdims = ['starting time'], vdims = ['Commute Time (min)'] )
return scatter
def DynamicDisplay(flag):
while flag > 0:
BokehDisplay()
time.sleep(10)
flag -= 1