I am trying to show two real-time data streaming plot with the code below. When I use one of them it works fine, but when I add the second they flicker simultaneously.
I discoverd is has something to do with the x-axis range. I added added range limits in the callback and it seems that changing the range of one of the plots changes the other as well. How can that be? They are completely separate right?
import panel as pn
import numpy as np
import holoviews as hv
from holoviews.streams import Buffer
from tornado.ioloop import PeriodicCallback
from tornado import gen
hv.extension('bokeh')
count_1 = 0
count_2 = 0
buffer_1 = Buffer(np.zeros((0, 2)), length=50)
buffer_2 = Buffer(np.zeros((0, 2)), length=50)
plot_1 = hv.DynamicMap(hv.Curve, streams=[buffer_1])
plot_2 = hv.DynamicMap(hv.Scatter, streams=[buffer_2])
@gen.coroutine
def callback_1():
global count_1
count_1 += 1
plot_1.opts(xlim=(0, 200))
buffer_1.send(np.array([[count_1, np.random.rand()]]))
@gen.coroutine
def callback_2():
global count_2
count_2 += 1
plot_2.opts(xlim=(0, 100))
buffer_2.send(np.array([[count_2, np.random.rand()]]))
PeriodicCallback(callback_1, 800).start()
PeriodicCallback(callback_2, 1000).start()
panel = pn.Row(plot_1, plot_2)
pn.serve(panel)