Hi, I’m very new to bokeh so sorry if I’m doing things absolutely wrong.
I have a python process with an active event loop that maintains an electrical grid which changes often. (this has nothing to do with plotting in itself)
From time to time a request comes in to plot a specfic node (e.g. potential and current) and I thus would like to show this plot with live data without hampering the main process.
I’ve been having a very difficult time getting this to work, mostly because I’m not familiar with the plotting world in general. I tried matplotlib etc but had most success with bokeh server for now.
My first somewhat working attempt involves running bokeh serve separately and when I want to plot a certain node create a Plot instance as in this code: http://dpaste.com/139380S
So basically I’m just running it in a thread, it works for a single plot but I don’t know how to make it work so that at a later stage another node should also be plotted for e.g. comparison.
Another approach I tried, was without the standalone bokeh serve : http://dpaste.com/04T8EKE.
I instantiate a new Plot object for a specific node I would like to plot and everytime its values change, I call plot.update_values(potential, current).
This works seemingly quite smooth, but I have the same issue in that I have no idea how to make this work for multiple plots. I could just create a new bokeh server each time on a separate port but that seems awfully inefficient.
My latest attempt for multiple plots is http://dpaste.com/3SBBA95.
I can’t really give the main running process, but you can just assume that at certain intervals plot.update_data would be called. So something like
plot = Plot()
while True:
plot.update_data(random(), random())
can be used as a very rudimentary main process that should not be interrupted.
I don’t expect a fully working solution, although it would be nice, but I’m just stuck at the moment and my limited experience in plotting prevents me from doing the right google searches.
So basically I need to find a way to show multiple live plots at undefined moments while my main process is running.
Thanks in advance.