Incredibly slow plotting using the bokeh server

Hello,

I’m trying to show the spread across a graph starting at the bottom left.

I’ve got it working currently with a slider to step through each iteration and see how it’s spreading, but it’s very very slow, you can see below:

The code I’m using to run this: from bokeh.plotting import figurefrom bokeh.io import curdocfrom bokeh.layou - Pastebin.com (I execute it using bokeh serve nameOfFile.py

I’ve attached the CSV file with the data i’m using, you’ll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

Thanks.

herdImmunityData.CSV (2.11 KB)

Hi again,

In another thread, you asked about how to do it in general.

I’ll send a piece of code there that should make it clear on how to approach the task.

Regarding why it’s slow - you plot multiple glyphs on each slider value change. Instead, you should just update relevant values inside a DataSource.

Regards,

Eugene

···

On Tuesday, October 10, 2017 at 11:06:41 PM UTC+7, R wrote:

Hello,

I’m trying to show the spread across a graph starting at the bottom left.

I’ve got it working currently with a slider to step through each iteration and see how it’s spreading, but it’s very very slow, you can see below:

The code I’m using to run this: https://pastebin.com/QidMJP0p (I execute it using bokeh serve nameOfFile.py

I’ve attached the CSV file with the data i’m using, you’ll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

Thanks.

Hi,

You have structured things in way that prevents Bokeh from doing things in an efficient way. Please study this example, which you should emulate:

  https://github.com/bokeh/bokeh/blob/master/examples/app/sliders.py

In particular, you should:

* put your data in numpy arrays (or pd Series) in a ColumnDataSource so that fast binary array transfer is available

* update the data to update the existing plot, don't create new plots every update, i.e don't call figure and circle over and over.

Thanks,

Bryan

···

On Oct 10, 2017, at 11:06, R <[email protected]> wrote:

Hello,

I'm trying to show the spread across a graph starting at the bottom left.
I've got it working currently with a slider to step through each iteration and see how it's spreading, but it's very very slow, you can see below:

The code I'm using to run this: https://pastebin.com/QidMJP0p (I execute it using bokeh serve nameOfFile.py
I've attached the CSV file with the data i'm using, you'll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

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/7cc9af1b-e671-40ba-9f15-329d1ed5a1a0%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.
<herdImmunityData.CSV>

You’ve deleted the previous post, so I’ll post the solution here: https://pastebin.com/BeeyhJH2
Another solution would be to create a custom color mapper that uses a threshold to choose colors.

Eugene

···

On Tuesday, October 10, 2017 at 11:06:41 PM UTC+7, R wrote:

Hello,

I’m trying to show the spread across a graph starting at the bottom left.

I’ve got it working currently with a slider to step through each iteration and see how it’s spreading, but it’s very very slow, you can see below:

The code I’m using to run this: https://pastebin.com/QidMJP0p (I execute it using bokeh serve nameOfFile.py

I’ve attached the CSV file with the data i’m using, you’ll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

Thanks.

Thanks Eugene, this is exactly what I was trying to achieve and with a much greater population too

···

On Wednesday, October 11, 2017 at 3:46:06 AM UTC+11, Eugene Pakhomov wrote:

You’ve deleted the previous post, so I’ll post the solution here: https://pastebin.com/BeeyhJH2
Another solution would be to create a custom color mapper that uses a threshold to choose colors.

Eugene

On Tuesday, October 10, 2017 at 11:06:41 PM UTC+7, R wrote:

Hello,

I’m trying to show the spread across a graph starting at the bottom left.

I’ve got it working currently with a slider to step through each iteration and see how it’s spreading, but it’s very very slow, you can see below:

The code I’m using to run this: https://pastebin.com/QidMJP0p (I execute it using bokeh serve nameOfFile.py

I’ve attached the CSV file with the data i’m using, you’ll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

Thanks.

Hello Eugene,

I was just wondering if it is possible to get the current value of a widget in a custom JavaScript function, and then update it?

For example; in your code you have a slider.js_on_change when the slider is changed to show the updated values.

I now want to add a play button to the slider so that it can play through the slider automatically.

I tried getting the element using document.getElementById but it seems the ID of the element is automatically assigned and not the same as my variable name.

The logic for playing would just be:

When button is pressed if it’s label is == play, change button label to pause, every X milliseconds increase the step slider value by 1.

else if it’s label is == pause, break/cancel.

Is this situation possible, or do I need to be using bokeh-server with the gapminder example of play/pause slider?

Thanks

···

On Wednesday, October 11, 2017 at 3:46:06 AM UTC+11, Eugene Pakhomov wrote:

You’ve deleted the previous post, so I’ll post the solution here: https://pastebin.com/BeeyhJH2
Another solution would be to create a custom color mapper that uses a threshold to choose colors.

Eugene

On Tuesday, October 10, 2017 at 11:06:41 PM UTC+7, R wrote:

Hello,

I’m trying to show the spread across a graph starting at the bottom left.

I’ve got it working currently with a slider to step through each iteration and see how it’s spreading, but it’s very very slow, you can see below:

The code I’m using to run this: https://pastebin.com/QidMJP0p (I execute it using bokeh serve nameOfFile.py

I’ve attached the CSV file with the data i’m using, you’ll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

Thanks.

Hi,

You can use “js_on_click” method of a button and pass it a CustomJS handler with one of the args set to the slider instance.

In the code of this handler, you’ll be able to call “slider.value = %compute new value%; slider.change.emit();”

Please refer to https://bokeh.pydata.org/en/latest/docs/user_guide/interaction/callbacks.html for more details.

Eugene

···

On Wednesday, October 11, 2017 at 6:13:53 PM UTC+7, R wrote:

Hello Eugene,

I was just wondering if it is possible to get the current value of a widget in a custom JavaScript function, and then update it?

For example; in your code you have a slider.js_on_change when the slider is changed to show the updated values.

I now want to add a play button to the slider so that it can play through the slider automatically.

I tried getting the element using document.getElementById but it seems the ID of the element is automatically assigned and not the same as my variable name.

The logic for playing would just be:

When button is pressed if it’s label is == play, change button label to pause, every X milliseconds increase the step slider value by 1.

else if it’s label is == pause, break/cancel.

Is this situation possible, or do I need to be using bokeh-server with the gapminder example of play/pause slider?

Thanks

On Wednesday, October 11, 2017 at 3:46:06 AM UTC+11, Eugene Pakhomov wrote:

You’ve deleted the previous post, so I’ll post the solution here: https://pastebin.com/BeeyhJH2
Another solution would be to create a custom color mapper that uses a threshold to choose colors.

Eugene

On Tuesday, October 10, 2017 at 11:06:41 PM UTC+7, R wrote:

Hello,

I’m trying to show the spread across a graph starting at the bottom left.

I’ve got it working currently with a slider to step through each iteration and see how it’s spreading, but it’s very very slow, you can see below:

The code I’m using to run this: https://pastebin.com/QidMJP0p (I execute it using bokeh serve nameOfFile.py

I’ve attached the CSV file with the data i’m using, you’ll have to update the directory path at the bottom of the code if you intend to run it.

Is there anyway to achieve my result and have the plotting of the lines/circles much much faster?

Thanks.