我想使用全息视图显示散射图并每 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