create new streaming plots during runtime

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.

Hi, I’m new to bokeh as well but I was experimenting on something similar to your task lately.
Here my example, (run just with python script.py) I put the server in a subprocess, I used bokeh.client
and I put the session loop is in a thread, then from my script workflow I can plot some things at anytime using doc.[add_next_tick_callback()](http://bokeh.pydata.org/en/latest/docs/reference/document.html#bokeh.document.Document.add_next_tick_callback),
that, to my understanding, add a callback to be executed whenever the tornado IOloop of the client is available.

I’m able to add new figure in the document at any time (you can try the add/del fig button in the example),

but i’m still investigating if it’s possible to add new lines in a figure that is already inside a document.

I will appreciate comments or clarifications.

···

On 16 March 2017 at 18:57, [email protected] wrote:

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.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/54539c30-883a-47ec-ba45-e107a88eab58%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Hi, I finally had the opportunity to play with your script, after some modifications I got it working like I want, thanks a lot!
The add_next_tick_callback in combination with the tornado generators really are a nice trick.

I have one final annoyance I’m not sure how to fix and that has to do with the x axis. As I’m plotting realtime data it’s a continuous advancement on the x axis causing everything to compress on eachother.

I can fix this by providing a rollover argument to the stream method. Although this does keep the plots pleasant to view, it causes dataloss.

Is there a way I can fix the amount of elements on the x axis while still allowing me to go back and forth in the data and still appending new data at the end even if I’m not looking at that range?

···

Op donderdag 16 maart 2017 21:11:24 UTC+1 schreef Tommaso Sartor:

I’m able to add new figure in the document at any time (you can try the add/del fig button in the example),

but i’m still investigating if it’s possible to add new lines in a figure that is already inside a document.

I will appreciate comments or clarifications.

Hi, I’m new to bokeh as well but I was experimenting on something similar to your task lately.
Here my example, (run just with python script.py) I put the server in a subprocess, I used bokeh.client
and I put the session loop is in a thread, then from my script workflow I can plot some things at anytime using doc.[add_next_tick_callback()](http://bokeh.pydata.org/en/latest/docs/reference/document.html#bokeh.document.Document.add_next_tick_callback),
that, to my understanding, add a callback to be executed whenever the tornado IOloop of the client is available.

On 16 March 2017 at 18:57, [email protected] wrote:

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.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/54539c30-883a-47ec-ba45-e107a88eab58%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Actually I had the same problem with the rollover option.
I discovered that one can play more with the DataRange1d object which implement the figure axis range,
to overcome the compressing plot problem I set the following options:

self.fig.x_range.follow = "end"

self.fig.x_range.follow_interval = 10

The follow="end" attribute tells the renderer to set the visualization window end to the maximum x value among data already plotted.
The follow_interval instead sets the x extension of visualization windows in the x_range unit.

In this way you preserve past data, but can keep plotted data zoom and aspect ratio constant.
Not sure if this is what you are searching for.
I also updated my example script.

···

On Monday, 20 March 2017 16:10:49 UTC+1, Darragh Van Tichelen wrote:

Hi, I finally had the opportunity to play with your script, after some modifications I got it working like I want, thanks a lot!
The add_next_tick_callback in combination with the tornado generators really are a nice trick.

I have one final annoyance I’m not sure how to fix and that has to do with the x axis. As I’m plotting realtime data it’s a continuous advancement on the x axis causing everything to compress on eachother.

I can fix this by providing a rollover argument to the stream method. Although this does keep the plots pleasant to view, it causes dataloss.

Is there a way I can fix the amount of elements on the x axis while still allowing me to go back and forth in the data and still appending new data at the end even if I’m not looking at that range?

Op donderdag 16 maart 2017 21:11:24 UTC+1 schreef Tommaso Sartor:

I’m able to add new figure in the document at any time (you can try the add/del fig button in the example),

but i’m still investigating if it’s possible to add new lines in a figure that is already inside a document.

I will appreciate comments or clarifications.

Hi, I’m new to bokeh as well but I was experimenting on something similar to your task lately.
Here my example, (run just with python script.py) I put the server in a subprocess, I used bokeh.client
and I put the session loop is in a thread, then from my script workflow I can plot some things at anytime using doc.[add_next_tick_callback()](http://bokeh.pydata.org/en/latest/docs/reference/document.html#bokeh.document.Document.add_next_tick_callback),
that, to my understanding, add a callback to be executed whenever the tornado IOloop of the client is available.

On 16 March 2017 at 18:57, [email protected] wrote:

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.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/54539c30-883a-47ec-ba45-e107a88eab58%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Great that’s exactly what I meant.

Removing figures from the column object is proving to be a problem in my usecase though, could you perhaps take a look at Redirecting to Google Groups ?

Thanks for the help so far!

···

Op dinsdag 28 maart 2017 01:31:21 UTC+2 schreef Tommaso Sartor:

Actually I had the same problem with the rollover option.
I discovered that one can play more with the DataRange1d object which implement the figure axis range,
to overcome the compressing plot problem I set the following options:

self.fig.x_range.follow = "end"

self.fig.x_range.follow_interval = 10

The `follow="end"` attribute tells the renderer to set the visualization window end to the maximum x value among data already plotted.
The `follow_interval` instead sets the x extension of visualization windows in the x_range unit.

In this way you preserve past data, but can keep plotted data zoom and aspect ratio constant.
Not sure if this is what you are searching for.
I also updated my example script.

On Monday, 20 March 2017 16:10:49 UTC+1, Darragh Van Tichelen wrote:

Hi, I finally had the opportunity to play with your script, after some modifications I got it working like I want, thanks a lot!
The add_next_tick_callback in combination with the tornado generators really are a nice trick.

I have one final annoyance I’m not sure how to fix and that has to do with the x axis. As I’m plotting realtime data it’s a continuous advancement on the x axis causing everything to compress on eachother.

I can fix this by providing a rollover argument to the stream method. Although this does keep the plots pleasant to view, it causes dataloss.

Is there a way I can fix the amount of elements on the x axis while still allowing me to go back and forth in the data and still appending new data at the end even if I’m not looking at that range?

Op donderdag 16 maart 2017 21:11:24 UTC+1 schreef Tommaso Sartor:

I’m able to add new figure in the document at any time (you can try the add/del fig button in the example),

but i’m still investigating if it’s possible to add new lines in a figure that is already inside a document.

I will appreciate comments or clarifications.

Hi, I’m new to bokeh as well but I was experimenting on something similar to your task lately.
Here my example, (run just with python script.py) I put the server in a subprocess, I used bokeh.client
and I put the session loop is in a thread, then from my script workflow I can plot some things at anytime using doc.[add_next_tick_callback()](http://bokeh.pydata.org/en/latest/docs/reference/document.html#bokeh.document.Document.add_next_tick_callback),
that, to my understanding, add a callback to be executed whenever the tornado IOloop of the client is available.

On 16 March 2017 at 18:57, [email protected] wrote:

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.

You received this message because you are subscribed to the Google Groups “Bokeh Discussion - Public” group.

To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].

To post to this group, send email to [email protected].

To view this discussion on the web visit https://groups.google.com/a/continuum.io/d/msgid/bokeh/54539c30-883a-47ec-ba45-e107a88eab58%40continuum.io.

For more options, visit https://groups.google.com/a/continuum.io/d/optout.