A few notes:
This is inefficient:
ard_humd.data_source.data["x"] = np.linspace(-10*len(AH_store), 0, len(AH_store))
ard_humd.data_source.data["y"] = AH_store
Since it triggers two patch messages to the server. If you need to update all the data, you should always prefer to update the entire .data attribute in one go, something like:
new_data = ard_humd.data_source.data
# update the regular python new_data dict here
# this triggers a single message to the server
ard_humd.data_source.data = new_data
However, this is sending *all* the data, on every update. If you just need to add a small number of new values (to *every* column in a given column data source, simultaneously --- remember all columns in a single CDS always needs to be the same length, think of CDS as a cheap DataFrame), you should look into the .stream method on column data source, demonstrated here:
https://github.com/bokeh/bokeh/blob/master/examples/app/ohlc/main.py#L61-L95
This method takes a dict with just the new data for each column, and sends only that smaller update to the server (optionally rolling over to a fixed buffer size if asked for).
Of course, .stream is only useful if you are wanting to add new points to existing data (imagine a streaming updating time series, where you just need to send the newest points every update). If your use-case is such that you actually need to replace all the data on every update, well then you have to replace all the data... In which case the questions are: How big is AH_store, and: What is your update rate? For instance, if AH_store is 10,000 and you are updating at 30 Hz, it's probably not going to work currently. Perhaps when the binary array protocol can be added, update rates like that will possible. If the size*rate is much lower, then I would expect it to work, won't be able to say much more without a minimal, complete, runnable example that reproduces the problem to investigate.
Thanks,
Bryan
···
On Mar 3, 2016, at 9:29 AM, RedRaven <[email protected]> wrote:
Nobody? let me add some more information. The data update happens in a callback function:
def update():
H_store.append(humidity) # store the humidity value in an array
ard_humd.data_source.data["x"] = np.linspace(-10*len(AH_store), 0, len(AH_store))
ard_humd.data_source.data["y"] = AH_store
the update function is periodically called to update the plot. Here is my update call.
curdoc().add_periodic_callback(update, 100)
I tested the functionality across Chrome, Firefox and IE. It looks like if I increase the callback interval it does not free. However, if I increase the callback too much I will start to lag behind the real-time process.
Its my impression that Bokeh is supposed to help with real-time graphics. How can I optimize this so that Im not freezing the plot updates but Im also fast enough for the process.
Anyone?
On Wednesday, 2 March 2016 17:54:52 UTC-5, RedRaven wrote:
Hi All,
I'm trying to plot data streaming from a room humidity sensor. The data plots file for a few points then almost stops updating despite new points coming in. Ive tried this in both Firefox and Chrome with the same effect. Here is my plot setup:
# Setup the room humidity
p_humd = figure(plot_width=250,plot_height=250,x_range=(-300,0), y_range=(20,40),title_text_font_size='8pt', toolbar_location=None)
p_humd.outline_line_color = "navy"
p_humd.outline_line_width = 7
p_humd.outline_line_alpha = 0.3
p_humd.background_fill_color = 'white'
p_humd.outline_line_color = None
p_humd.grid.grid_line_color = None
ard_humd = p_humd.line(x=, y=,color='navy', line_width=4)
p_humd.title = "Relative Humidity"
p_humd.xaxis.axis_label = 'seconds'
p_humd.yaxis.axis_label = '%'
p_humd.xaxis.axis_label_text_font_size = '8pt'
p_humd.yaxis.axis_label_text_font_size = '8pt'
Here is how I update the data in the plot:
H_store.append(humidity) # store the humidity value in an array
ard_humd.data_source.data["x"] = np.linspace(-10*len(AH_store), 0, len(AH_store))
ard_humd.data_source.data["y"] = AH_store
Why is this so slow?
Thanks!
--
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/5d2665be-bc72-48b2-aac9-9b020d30891b%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.