I want to display a scattering plot using holoviews and update the plot every 10 seconds. Therefore I wrote a function "BokehDisplay" to plot the scattering plot without updating, then I added another function "DynamicDisplay" to update the scattering plot every 10 seconds. However, the scattering plot only showed up when I ran the first function, but not when I ran the second function. Any hints would be highly appreciated! Thanks!
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