I am trying to add lines to a blank plot on-the-fly. I am planning on creating these lines once in a periodic callback as worker hosts come online. However, when I do this, the lines continue to flicker almost like the lines are being replotted continuously. I have prototyped this behavior in the following minimal example which is also attached. Please let me know of a way to be able to add lines to a plot on-the-fly without knowing them all upfront.
"""Streams data to memory plot.
"""
for i in range(5):
if str(i) not in SOURCES:
print("Creating line", i)
source = bokeh.models.ColumnDataSource(
data={'time': [], 'memory': []})
PLOT.line('time', 'memory', source=source)
data = {'time': [0.0, 1.0], 'memory': [0.0, 2.0*(i+1.0)]}
source.stream(data, 50)
SOURCES[str(i)] = source
The typical pattern is to create all the plots and renderers and data sources up front (i.e. *not* in the periodic callback) and then use the callback to *update* the existing data sources (which causes the plots and renderers to update accordingly). Your current code is creating and transmitting five new line renderers and data sources every half second. That is probably not what you intend, if you are using stream (which is expressly useful for updating existing data sources, i.e, for *not* having to create and send all the data).
You might want to start with this example as a template to study:
I am trying to add lines to a blank plot on-the-fly. I am planning on creating these lines once in a periodic callback as worker hosts come online. However, when I do this, the lines continue to flicker almost like the lines are being replotted continuously. I have prototyped this behavior in the following minimal example which is also attached. Please let me know of a way to be able to add lines to a plot on-the-fly without knowing them all upfront.
I should clarify: I am suggesting adding all the potential line renderers and *empty* data sources up front, that will result in an empty plot (because the data sources are empty).
Thanks,
Bryan
···
On Nov 4, 2016, at 11:14 AM, Bryan Van de Ven <[email protected]> wrote:
Hi,
The typical pattern is to create all the plots and renderers and data sources up front (i.e. *not* in the periodic callback) and then use the callback to *update* the existing data sources (which causes the plots and renderers to update accordingly). Your current code is creating and transmitting five new line renderers and data sources every half second. That is probably not what you intend, if you are using stream (which is expressly useful for updating existing data sources, i.e, for *not* having to create and send all the data).
You might want to start with this example as a template to study:
I am trying to add lines to a blank plot on-the-fly. I am planning on creating these lines once in a periodic callback as worker hosts come online. However, when I do this, the lines continue to flicker almost like the lines are being replotted continuously. I have prototyped this behavior in the following minimal example which is also attached. Please let me know of a way to be able to add lines to a plot on-the-fly without knowing them all upfront.
All that said, this seems like a bug, so I'd encourage yo uto make an issue with this code on the issue tracker.
Thanks,
Bryan
···
On Nov 4, 2016, at 11:23 AM, Bryan Van de Ven <[email protected]> wrote:
I should clarify: I am suggesting adding all the potential line renderers and *empty* data sources up front, that will result in an empty plot (because the data sources are empty).
Thanks,
Bryan
On Nov 4, 2016, at 11:14 AM, Bryan Van de Ven <[email protected]> wrote:
Hi,
The typical pattern is to create all the plots and renderers and data sources up front (i.e. *not* in the periodic callback) and then use the callback to *update* the existing data sources (which causes the plots and renderers to update accordingly). Your current code is creating and transmitting five new line renderers and data sources every half second. That is probably not what you intend, if you are using stream (which is expressly useful for updating existing data sources, i.e, for *not* having to create and send all the data).
You might want to start with this example as a template to study:
I am trying to add lines to a blank plot on-the-fly. I am planning on creating these lines once in a periodic callback as worker hosts come online. However, when I do this, the lines continue to flicker almost like the lines are being replotted continuously. I have prototyped this behavior in the following minimal example which is also attached. Please let me know of a way to be able to add lines to a plot on-the-fly without knowing them all upfront.
On Nov 4, 2016, at 11:23 AM, Bryan Van de Ven <[email protected]> wrote:
I should clarify: I am suggesting adding all the potential line renderers and *empty* data sources up front, that will result in an empty plot (because the data sources are empty).
Thanks,
Bryan
On Nov 4, 2016, at 11:14 AM, Bryan Van de Ven <[email protected]> wrote:
Hi,
The typical pattern is to create all the plots and renderers and data sources up front (i.e. *not* in the periodic callback) and then use the callback to *update* the existing data sources (which causes the plots and renderers to update accordingly). Your current code is creating and transmitting five new line renderers and data sources every half second. That is probably not what you intend, if you are using stream (which is expressly useful for updating existing data sources, i.e, for *not* having to create and send all the data).
You might want to start with this example as a template to study:
I am trying to add lines to a blank plot on-the-fly. I am planning on creating these lines once in a periodic callback as worker hosts come online. However, when I do this, the lines continue to flicker almost like the lines are being replotted continuously. I have prototyped this behavior in the following minimal example which is also attached. Please let me know of a way to be able to add lines to a plot on-the-fly without knowing them all upfront.