Slight delay on click of rect() figure square

I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed

Is there some way to avoid this small delay in a rec() glyph?

Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.

import numpy as np

import pandas as pd

from bokeh.plotting import figure, show, reset_output

from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d

from bokeh.transform import transform

size = 150

#Creating random data to fill heatmap

df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list(‘ABCD’))

df[‘Y’] = list(range(1,size+1))*size

df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]

colors.reverse()

mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(

width = 1000,

height = 1000,

tools=[“hover”,“tap”,“save”,“reset”,“wheel_zoom”],

x_axis_location=“above”,

active_drag=None,

toolbar_location=“right”,

toolbar_sticky = False,

)

Create rectangle for heatmap

mysource = ColumnDataSource(df)

p.rect(

y=“Y”,

x=“X”,

width=1,

height=1,

source=mysource,

line_color=“white”,

fill_color=transform(“C”, mapper),

set visual properties for selected glyphs

selection_line_color=“black”,

selection_fill_color=transform(“C”, mapper),

set visual properties for non-selected glyphs

nonselection_fill_color=transform(“C”, mapper),

nonselection_fill_alpha=1,

nonselection_line_alpha=1,

nonselection_line_color=“white”

)

show§

reset_output()

``

heatmap_plot.html (561 KB)

I can't seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.

Thanks,

Bryan

···

On May 14, 2019, at 6:30 AM, [email protected] <[email protected]> wrote:

I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed

Is there some way to avoid this small delay in a rec() glyph?

Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.
import numpy as np
import pandas as pd
from bokeh.plotting import figure, show, reset_output
from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
from bokeh.transform import transform

size = 150

#Creating random data to fill heatmap
df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list('ABCD'))
df['Y'] = list(range(1,size+1))*size
df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

# Mapper
colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
colors.reverse()
mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(
    width = 1000,
    height = 1000,
    tools=["hover","tap","save","reset","wheel_zoom"],
    x_axis_location="above",
    active_drag=None,
    toolbar_location="right",
    toolbar_sticky = False,
)

# Create rectangle for heatmap
mysource = ColumnDataSource(df)
p.rect(
    y="Y",
    x="X",
    width=1,
    height=1,
    source=mysource,
    line_color="white",
    fill_color=transform("C", mapper),

    # set visual properties for selected glyphs
    selection_line_color="black",
    selection_fill_color=transform("C", mapper),
    # set visual properties for non-selected glyphs
    nonselection_fill_color=transform("C", mapper),
    nonselection_fill_alpha=1,
    nonselection_line_alpha=1,
    nonselection_line_color="white"
    )
show(p)
reset_output()

--
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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<heatmap_plot.html>

Hi Bryan,

Thanks for your quick answer. It is true, indeed, that plot performance is significanctly better when rendered with bokeh 1.1.0. The issue persists, nevertheless. To make it more visible, I have attached a script to generate a huge rect() plot, as big as the ones I’m using on my web.

The problem I reffer to is the sligth dealy and plot-freeze when one of the rectangles is clicked. Is there any way to avoid it?

Find attached the code to generate the aforementioned plot

import numpy as np

import pandas as pd

from bokeh.plotting import figure, show, reset_output

from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d

from bokeh.transform import transform

size = 500

#Creating random data to fill heatmap

df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list(‘ABCD’))

df[‘Y’] = list(range(1,size+1))*size

df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

print(df)

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]

colors.reverse()

mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(

width = 10000,

height = 10000,

tools=[“hover”,“tap”,“save”,“reset”,“wheel_zoom”],

x_axis_location=“above”,

active_drag=None,

toolbar_location=“right”,

toolbar_sticky = False,

)

Create rectangle for heatmap

mysource = ColumnDataSource(df)

p.rect(

y=“Y”,

x=“X”,

width=1,

height=1,

source=mysource,

line_color=“white”,

fill_color=transform(“C”, mapper),

set visual properties for selected glyphs

selection_line_color=“black”,

selection_fill_color=transform(“C”, mapper),

set visual properties for non-selected glyphs

nonselection_fill_color=transform(“C”, mapper),

nonselection_fill_alpha=1,

nonselection_line_alpha=1,

nonselection_line_color=“white”

)

show§

reset_output()

``

···

El martes, 14 de mayo de 2019, 17:22:09 (UTC+2), Bryan Van de Ven escribió:

I can’t seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.

Thanks,

Bryan

On May 14, 2019, at 6:30 AM, [email protected] [email protected] wrote:

I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed

Is there some way to avoid this small delay in a rec() glyph?

Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.

import numpy as np

import pandas as pd

from bokeh.plotting import figure, show, reset_output

from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d

from bokeh.transform import transform

size = 150

#Creating random data to fill heatmap

df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list(‘ABCD’))

df[‘Y’] = list(range(1,size+1))*size

df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]

colors.reverse()

mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(

width = 1000,
height = 1000,
tools=["hover","tap","save","reset","wheel_zoom"],
x_axis_location="above",
active_drag=None,
toolbar_location="right",
toolbar_sticky = False,

)

Create rectangle for heatmap

mysource = ColumnDataSource(df)

p.rect(

y="Y",
x="X",
width=1,
height=1,
source=mysource,
line_color="white",
fill_color=transform("C", mapper),
# set visual properties for selected glyphs
selection_line_color="black",
selection_fill_color=transform("C", mapper),
# set visual properties for non-selected glyphs
nonselection_fill_color=transform("C", mapper),
nonselection_fill_alpha=1,
nonselection_line_alpha=1,
nonselection_line_color="white"
)

show§

reset_output()


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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.

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

<heatmap_plot.html>

Hi,

I'm not sure I understand, is your real plot actually 10000x10000? That is *far* beyond standard use cases. I am surprised that even renders at all on most/any browsers. It won't come up at all for me on Safari, e.g. If it works at all I would not be surprised at things being slow in various ways.

250k points is also on the edge for standard Bokeh. You might try enabling webgl to improve rendering time, but please be advised there is not currently an active maintainer for Bokeh's webgl support, so your mileage may vary. Also it's entirely possible that the slowness is simply in the spatial indexing/hit testing and that Bokeh is just not a good tool for this situation.

Thanks,

Bryan

···

On May 16, 2019, at 5:42 AM, [email protected] wrote:

Hi Bryan,

Thanks for your quick answer. It is true, indeed, that plot performance is significanctly better when rendered with bokeh 1.1.0. The issue persists, nevertheless. To make it more visible, I have attached a script to generate a huge rect() plot, as big as the ones I'm using on my web.

The problem I reffer to is the sligth dealy and plot-freeze when one of the rectangles is clicked. Is there any way to avoid it?

Find attached the code to generate the aforementioned plot
import numpy as np
import pandas as pd
from bokeh.plotting import figure, show, reset_output
from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
from bokeh.transform import transform

size = 500

#Creating random data to fill heatmap
df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list('ABCD'))
df['Y'] = list(range(1,size+1))*size
df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
print(df)
# Mapper
colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
colors.reverse()
mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(
    width = 10000,
    height = 10000,
    tools=["hover","tap","save","reset","wheel_zoom"],
    x_axis_location="above",
    active_drag=None,
    toolbar_location="right",
    toolbar_sticky = False,
)

# Create rectangle for heatmap
mysource = ColumnDataSource(df)
p.rect(
    y="Y",
    x="X",
    width=1,
    height=1,
    source=mysource,
    line_color="white",
    fill_color=transform("C", mapper),

    # set visual properties for selected glyphs
    selection_line_color="black",
    selection_fill_color=transform("C", mapper),
    # set visual properties for non-selected glyphs
    nonselection_fill_color=transform("C", mapper),
    nonselection_fill_alpha=1,
    nonselection_line_alpha=1,
    nonselection_line_color="white"
    )
show(p)
reset_output()

El martes, 14 de mayo de 2019, 17:22:09 (UTC+2), Bryan Van de Ven escribió:
I can't seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.

Thanks,

Bryan

> On May 14, 2019, at 6:30 AM, [email protected] <[email protected]> wrote:
>
> I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed
>
> Is there some way to avoid this small delay in a rec() glyph?
>
> Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.
> import numpy as np
> import pandas as pd
> from bokeh.plotting import figure, show, reset_output
> from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
> from bokeh.transform import transform
>
> size = 150
>
> #Creating random data to fill heatmap
> df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list('ABCD'))
> df['Y'] = list(range(1,size+1))*size
> df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
>
> # Mapper
> colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
> colors.reverse()
> mapper = LinearColorMapper(palette=colors, low=0, high=100)
>
> p = figure(
> width = 1000,
> height = 1000,
> tools=["hover","tap","save","reset","wheel_zoom"],
> x_axis_location="above",
> active_drag=None,
> toolbar_location="right",
> toolbar_sticky = False,
> )
>
> # Create rectangle for heatmap
> mysource = ColumnDataSource(df)
> p.rect(
> y="Y",
> x="X",
> width=1,
> height=1,
> source=mysource,
> line_color="white",
> fill_color=transform("C", mapper),
>
> # set visual properties for selected glyphs
> selection_line_color="black",
> selection_fill_color=transform("C", mapper),
> # set visual properties for non-selected glyphs
> nonselection_fill_color=transform("C", mapper),
> nonselection_fill_alpha=1,
> nonselection_line_alpha=1,
> nonselection_line_color="white"
> )
> show(p)
> reset_output()
>
>
>
> --
> 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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.
> <heatmap_plot.html>

--
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/7e29da75-f57c-4517-9687-b6eceb61be90%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

The previous example was perhaps kind of exaggerated. My largest plot is 2564x16300. That was the limit for my browser apparently: wider plots did not render. This larger plot has about 158k points, which is way less than the example I have published.

The delay thing happens nevertheless in all plots, but is more exaggerated in bigger ones while imperceptible in smaller ones. It seems like the whole plot has to render again every time a point is clicked. In any case, thanks for your help.

···

El jueves, 16 de mayo de 2019, 17:27:23 (UTC+2), Bryan Van de Ven escribió:

Hi,

I’m not sure I understand, is your real plot actually 10000x10000? That is far beyond standard use cases. I am surprised that even renders at all on most/any browsers. It won’t come up at all for me on Safari, e.g. If it works at all I would not be surprised at things being slow in various ways.

250k points is also on the edge for standard Bokeh. You might try enabling webgl to improve rendering time, but please be advised there is not currently an active maintainer for Bokeh’s webgl support, so your mileage may vary. Also it’s entirely possible that the slowness is simply in the spatial indexing/hit testing and that Bokeh is just not a good tool for this situation.

Thanks,

Bryan

On May 16, 2019, at 5:42 AM, [email protected] wrote:

Hi Bryan,

Thanks for your quick answer. It is true, indeed, that plot performance is significanctly better when rendered with bokeh 1.1.0. The issue persists, nevertheless. To make it more visible, I have attached a script to generate a huge rect() plot, as big as the ones I’m using on my web.

The problem I reffer to is the sligth dealy and plot-freeze when one of the rectangles is clicked. Is there any way to avoid it?

Find attached the code to generate the aforementioned plot
import numpy as np

import pandas as pd

from bokeh.plotting import figure, show, reset_output

from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d

from bokeh.transform import transform

size = 500

#Creating random data to fill heatmap

df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list(‘ABCD’))

df[‘Y’] = list(range(1,size+1))*size

df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

print(df)

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]

colors.reverse()

mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(

width = 10000,
height = 10000,
tools=["hover","tap","save","reset","wheel_zoom"],
x_axis_location="above",
active_drag=None,
toolbar_location="right",
toolbar_sticky = False,

)

Create rectangle for heatmap

mysource = ColumnDataSource(df)

p.rect(

y="Y",
x="X",
width=1,
height=1,
source=mysource,
line_color="white",
fill_color=transform("C", mapper),
# set visual properties for selected glyphs
selection_line_color="black",
selection_fill_color=transform("C", mapper),
# set visual properties for non-selected glyphs
nonselection_fill_color=transform("C", mapper),
nonselection_fill_alpha=1,
nonselection_line_alpha=1,
nonselection_line_color="white"
)

show§

reset_output()

El martes, 14 de mayo de 2019, 17:22:09 (UTC+2), Bryan Van de Ven escribió:

I can’t seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.

Thanks,

Bryan

On May 14, 2019, at 6:30 AM, [email protected] [email protected] wrote:

I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed

Is there some way to avoid this small delay in a rec() glyph?

Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.
import numpy as np
import pandas as pd
from bokeh.plotting import figure, show, reset_output
from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
from bokeh.transform import transform

size = 150

#Creating random data to fill heatmap
df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list(‘ABCD’))
df[‘Y’] = list(range(1,size+1))*size
df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]
colors.reverse()
mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(
width = 1000,
height = 1000,
tools=[“hover”,“tap”,“save”,“reset”,“wheel_zoom”],
x_axis_location=“above”,
active_drag=None,
toolbar_location=“right”,
toolbar_sticky = False,
)

Create rectangle for heatmap

mysource = ColumnDataSource(df)
p.rect(
y=“Y”,
x=“X”,
width=1,
height=1,
source=mysource,
line_color=“white”,
fill_color=transform(“C”, mapper),

# set visual properties for selected glyphs
selection_line_color="black",
selection_fill_color=transform("C", mapper),
# set visual properties for non-selected glyphs
nonselection_fill_color=transform("C", mapper),
nonselection_fill_alpha=1,
nonselection_line_alpha=1,
nonselection_line_color="white"
)

show§
reset_output()


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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<heatmap_plot.html>


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/7e29da75-f57c-4517-9687-b6eceb61be90%40continuum.io.

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

Hi,

Yes, Bokeh is a bitmapped canvas-based rendering library, so it is absolutely the case the the entire canvas has to be re-rendered to update any part of it (e.g. to highlight one glyph)

Thanks.

Bryan

···

On May 17, 2019, at 2:30 AM, [email protected] wrote:

The previous example was perhaps kind of exaggerated. My largest plot is 2564x16300. That was the limit for my browser apparently: wider plots did not render. This larger plot has about 158k points, which is way less than the example I have published.

The delay thing happens nevertheless in all plots, but is more exaggerated in bigger ones while imperceptible in smaller ones. It seems like the whole plot has to render again every time a point is clicked. In any case, thanks for your help.

El jueves, 16 de mayo de 2019, 17:27:23 (UTC+2), Bryan Van de Ven escribió:
Hi,

I'm not sure I understand, is your real plot actually 10000x10000? That is *far* beyond standard use cases. I am surprised that even renders at all on most/any browsers. It won't come up at all for me on Safari, e.g. If it works at all I would not be surprised at things being slow in various ways.

250k points is also on the edge for standard Bokeh. You might try enabling webgl to improve rendering time, but please be advised there is not currently an active maintainer for Bokeh's webgl support, so your mileage may vary. Also it's entirely possible that the slowness is simply in the spatial indexing/hit testing and that Bokeh is just not a good tool for this situation.

Thanks,

Bryan

> On May 16, 2019, at 5:42 AM, [email protected] wrote:
>
> Hi Bryan,
>
> Thanks for your quick answer. It is true, indeed, that plot performance is significanctly better when rendered with bokeh 1.1.0. The issue persists, nevertheless. To make it more visible, I have attached a script to generate a huge rect() plot, as big as the ones I'm using on my web.
>
> The problem I reffer to is the sligth dealy and plot-freeze when one of the rectangles is clicked. Is there any way to avoid it?
>
> Find attached the code to generate the aforementioned plot
> import numpy as np
> import pandas as pd
> from bokeh.plotting import figure, show, reset_output
> from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
> from bokeh.transform import transform
>
> size = 500
>
> #Creating random data to fill heatmap
> df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list('ABCD'))
> df['Y'] = list(range(1,size+1))*size
> df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
> print(df)
> # Mapper
> colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
> colors.reverse()
> mapper = LinearColorMapper(palette=colors, low=0, high=100)
>
> p = figure(
> width = 10000,
> height = 10000,
> tools=["hover","tap","save","reset","wheel_zoom"],
> x_axis_location="above",
> active_drag=None,
> toolbar_location="right",
> toolbar_sticky = False,
> )
>
> # Create rectangle for heatmap
> mysource = ColumnDataSource(df)
> p.rect(
> y="Y",
> x="X",
> width=1,
> height=1,
> source=mysource,
> line_color="white",
> fill_color=transform("C", mapper),
>
> # set visual properties for selected glyphs
> selection_line_color="black",
> selection_fill_color=transform("C", mapper),
> # set visual properties for non-selected glyphs
> nonselection_fill_color=transform("C", mapper),
> nonselection_fill_alpha=1,
> nonselection_line_alpha=1,
> nonselection_line_color="white"
> )
> show(p)
> reset_output()
>
>
>
>
> El martes, 14 de mayo de 2019, 17:22:09 (UTC+2), Bryan Van de Ven escribió:
> I can't seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.
>
> Thanks,
>
> Bryan
>
> > On May 14, 2019, at 6:30 AM, [email protected] <[email protected]> wrote:
> >
> > I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed
> >
> > Is there some way to avoid this small delay in a rec() glyph?
> >
> > Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.
> > import numpy as np
> > import pandas as pd
> > from bokeh.plotting import figure, show, reset_output
> > from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
> > from bokeh.transform import transform
> >
> > size = 150
> >
> > #Creating random data to fill heatmap
> > df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list('ABCD'))
> > df['Y'] = list(range(1,size+1))*size
> > df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
> >
> > # Mapper
> > colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
> > colors.reverse()
> > mapper = LinearColorMapper(palette=colors, low=0, high=100)
> >
> > p = figure(
> > width = 1000,
> > height = 1000,
> > tools=["hover","tap","save","reset","wheel_zoom"],
> > x_axis_location="above",
> > active_drag=None,
> > toolbar_location="right",
> > toolbar_sticky = False,
> > )
> >
> > # Create rectangle for heatmap
> > mysource = ColumnDataSource(df)
> > p.rect(
> > y="Y",
> > x="X",
> > width=1,
> > height=1,
> > source=mysource,
> > line_color="white",
> > fill_color=transform("C", mapper),
> >
> > # set visual properties for selected glyphs
> > selection_line_color="black",
> > selection_fill_color=transform("C", mapper),
> > # set visual properties for non-selected glyphs
> > nonselection_fill_color=transform("C", mapper),
> > nonselection_fill_alpha=1,
> > nonselection_line_alpha=1,
> > nonselection_line_color="white"
> > )
> > show(p)
> > reset_output()
> >
> >
> >
> > --
> > 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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout.
> > <heatmap_plot.html>
>
>
> --
> 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/7e29da75-f57c-4517-9687-b6eceb61be90%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/71dde2bd-0868-4903-87a3-7922872aa0cc%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Oh, I see.

Even so, If I wanted, for example, not to update anything from the plot, but only to launch some javascript with CustomJS() comand, could it be possible to do it without reuploading the whole plot?

See atached example:

import numpy as np

import pandas as pd

from bokeh.plotting import figure, show, reset_output

from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d, CustomJS

from bokeh.transform import transform

size = 500

#Creating random data to fill heatmap

df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list(‘ABCD’))

df[‘Y’] = list(range(1,size+1))*size

df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]

colors.reverse()

mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(

width = 10000,

height = 10000,

tools=[“hover”,“tap”,“save”,“reset”,“wheel_zoom”],

x_axis_location=“above”,

active_drag=None,

toolbar_location=“right”,

toolbar_sticky = False,

)

Create rectangle for heatmap

mysource = ColumnDataSource(df)

p.rect(

y=“Y”,

x=“X”,

width=1,

height=1,

source=mysource,

line_color=“white”,

fill_color=transform(“C”, mapper),

fill_alpha=1,

line_alpha=1,

)

mysource.callback = CustomJS(code = “”“window.alert(‘Hello world’)”"")

show§

reset_output()

``

···

El viernes, 17 de mayo de 2019, 15:57:19 (UTC+2), Bryan Van de Ven escribió:

Hi,

Yes, Bokeh is a bitmapped canvas-based rendering library, so it is absolutely the case the the entire canvas has to be re-rendered to update any part of it (e.g. to highlight one glyph)

Thanks.

Bryan

On May 17, 2019, at 2:30 AM, [email protected] wrote:

The previous example was perhaps kind of exaggerated. My largest plot is 2564x16300. That was the limit for my browser apparently: wider plots did not render. This larger plot has about 158k points, which is way less than the example I have published.

The delay thing happens nevertheless in all plots, but is more exaggerated in bigger ones while imperceptible in smaller ones. It seems like the whole plot has to render again every time a point is clicked. In any case, thanks for your help.

El jueves, 16 de mayo de 2019, 17:27:23 (UTC+2), Bryan Van de Ven escribió:

Hi,

I’m not sure I understand, is your real plot actually 10000x10000? That is far beyond standard use cases. I am surprised that even renders at all on most/any browsers. It won’t come up at all for me on Safari, e.g. If it works at all I would not be surprised at things being slow in various ways.

250k points is also on the edge for standard Bokeh. You might try enabling webgl to improve rendering time, but please be advised there is not currently an active maintainer for Bokeh’s webgl support, so your mileage may vary. Also it’s entirely possible that the slowness is simply in the spatial indexing/hit testing and that Bokeh is just not a good tool for this situation.

Thanks,

Bryan

On May 16, 2019, at 5:42 AM, [email protected] wrote:

Hi Bryan,

Thanks for your quick answer. It is true, indeed, that plot performance is significanctly better when rendered with bokeh 1.1.0. The issue persists, nevertheless. To make it more visible, I have attached a script to generate a huge rect() plot, as big as the ones I’m using on my web.

The problem I reffer to is the sligth dealy and plot-freeze when one of the rectangles is clicked. Is there any way to avoid it?

Find attached the code to generate the aforementioned plot
import numpy as np
import pandas as pd
from bokeh.plotting import figure, show, reset_output
from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
from bokeh.transform import transform

size = 500

#Creating random data to fill heatmap
df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list(‘ABCD’))
df[‘Y’] = list(range(1,size+1))*size
df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
print(df)

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]
colors.reverse()
mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(
width = 10000,
height = 10000,
tools=[“hover”,“tap”,“save”,“reset”,“wheel_zoom”],
x_axis_location=“above”,
active_drag=None,
toolbar_location=“right”,
toolbar_sticky = False,
)

Create rectangle for heatmap

mysource = ColumnDataSource(df)
p.rect(
y=“Y”,
x=“X”,
width=1,
height=1,
source=mysource,
line_color=“white”,
fill_color=transform(“C”, mapper),

# set visual properties for selected glyphs
selection_line_color="black",
selection_fill_color=transform("C", mapper),
# set visual properties for non-selected glyphs
nonselection_fill_color=transform("C", mapper),
nonselection_fill_alpha=1,
nonselection_line_alpha=1,
nonselection_line_color="white"
)

show§
reset_output()

El martes, 14 de mayo de 2019, 17:22:09 (UTC+2), Bryan Van de Ven escribió:
I can’t seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.

Thanks,

Bryan

On May 14, 2019, at 6:30 AM, [email protected] [email protected] wrote:

I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed

Is there some way to avoid this small delay in a rec() glyph?

Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.
import numpy as np
import pandas as pd
from bokeh.plotting import figure, show, reset_output
from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
from bokeh.transform import transform

size = 150

#Creating random data to fill heatmap
df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list(‘ABCD’))
df[‘Y’] = list(range(1,size+1))*size
df[‘X’] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

Mapper

colors = [’#FF0000’,’#FF0800’,’#FF1000’,’#FF1800’,’#FF2000’,’#FF2800’,’#FF3000’,’#FF3800’,’#FF4000’,’#FF4800’,’#FF5000’,’#FF5900’,’#FF6100’,’#FF6900’,’#FF7100’,’#FF7900’,’#FF8100’,’#FF8900’,’#FF9100’,’#FF9900’,’#FFA100’,’#FFAA00’,’#FFB200’,’#FFBA00’,’#FFC200’,’#FFCA00’,’#FFD200’,’#FFDA00’,’#FFE200’,’#FFEA00’,’#FFF200’,’#FFFA00’,’#FAFF00’,’#F2FF00’,’#EAFF00’,’#E2FF00’,’#DAFF00’,’#D2FF00’,’#CAFF00’,’#C2FF00’,’#BAFF00’,’#B2FF00’,’#AAFF00’,’#A1FF00’,’#99FF00’,’#91FF00’,’#89FF00’,’#81FF00’,’#79FF00’,’#71FF00’,’#69FF00’,’#61FF00’,’#59FF00’,’#50FF00’,’#48FF00’,’#40FF00’,’#38FF00’,’#30FF00’,’#28FF00’,’#20FF00’,’#18FF00’,’#10FF00’,’#08FF00’,’#00FF00’]
colors.reverse()
mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(
width = 1000,
height = 1000,
tools=[“hover”,“tap”,“save”,“reset”,“wheel_zoom”],
x_axis_location=“above”,
active_drag=None,
toolbar_location=“right”,
toolbar_sticky = False,
)

Create rectangle for heatmap

mysource = ColumnDataSource(df)
p.rect(
y=“Y”,
x=“X”,
width=1,
height=1,
source=mysource,
line_color=“white”,
fill_color=transform(“C”, mapper),

# set visual properties for selected glyphs
selection_line_color="black",
selection_fill_color=transform("C", mapper),
# set visual properties for non-selected glyphs
nonselection_fill_color=transform("C", mapper),
nonselection_fill_alpha=1,
nonselection_line_alpha=1,
nonselection_line_color="white"
)

show§
reset_output()


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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.
<heatmap_plot.html>


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/7e29da75-f57c-4517-9687-b6eceb61be90%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.


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/71dde2bd-0868-4903-87a3-7922872aa0cc%40continuum.io.

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

Once again, this example does not display on my system at all, on either Chrome or Safari. A plot of this size is out of scope for the Bokeh project.

As for the callback, if source.callback is executing, that means that source.selection has been set. If source.selection has been set, that triggers a render.

Thanks,

Bryan

···

On May 20, 2019, at 2:27 AM, [email protected] wrote:

Oh, I see.

Even so, If I wanted, for example, not to update anything from the plot, but only to launch some javascript with CustomJS() comand, could it be possible to do it without reuploading the whole plot?

See atached example:

import numpy as np
import pandas as pd
from bokeh.plotting import figure, show, reset_output
from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d, CustomJS
from bokeh.transform import transform

size = 500

#Creating random data to fill heatmap
df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list('ABCD'))
df['Y'] = list(range(1,size+1))*size
df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))

# Mapper
colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
colors.reverse()
mapper = LinearColorMapper(palette=colors, low=0, high=100)

p = figure(
    width = 10000,
    height = 10000,
    tools=["hover","tap","save","reset","wheel_zoom"],
    x_axis_location="above",
    active_drag=None,
    toolbar_location="right",
    toolbar_sticky = False,
)

# Create rectangle for heatmap
mysource = ColumnDataSource(df)
p.rect(
    y="Y",
    x="X",
    width=1,
    height=1,
    source=mysource,
    line_color="white",
    fill_color=transform("C", mapper),
    fill_alpha=1,
    line_alpha=1,
    )

mysource.callback = CustomJS(code = """window.alert('Hello world')""")

show(p)
reset_output()

El viernes, 17 de mayo de 2019, 15:57:19 (UTC+2), Bryan Van de Ven escribió:
Hi,

Yes, Bokeh is a bitmapped canvas-based rendering library, so it is absolutely the case the the entire canvas has to be re-rendered to update any part of it (e.g. to highlight one glyph)

Thanks.

Bryan

> On May 17, 2019, at 2:30 AM, [email protected] wrote:
>
> The previous example was perhaps kind of exaggerated. My largest plot is 2564x16300. That was the limit for my browser apparently: wider plots did not render. This larger plot has about 158k points, which is way less than the example I have published.
>
> The delay thing happens nevertheless in all plots, but is more exaggerated in bigger ones while imperceptible in smaller ones. It seems like the whole plot has to render again every time a point is clicked. In any case, thanks for your help.
>
> El jueves, 16 de mayo de 2019, 17:27:23 (UTC+2), Bryan Van de Ven escribió:
> Hi,
>
> I'm not sure I understand, is your real plot actually 10000x10000? That is *far* beyond standard use cases. I am surprised that even renders at all on most/any browsers. It won't come up at all for me on Safari, e.g. If it works at all I would not be surprised at things being slow in various ways.
>
> 250k points is also on the edge for standard Bokeh. You might try enabling webgl to improve rendering time, but please be advised there is not currently an active maintainer for Bokeh's webgl support, so your mileage may vary. Also it's entirely possible that the slowness is simply in the spatial indexing/hit testing and that Bokeh is just not a good tool for this situation.
>
> Thanks,
>
> Bryan
>
> > On May 16, 2019, at 5:42 AM, [email protected] wrote:
> >
> > Hi Bryan,
> >
> > Thanks for your quick answer. It is true, indeed, that plot performance is significanctly better when rendered with bokeh 1.1.0. The issue persists, nevertheless. To make it more visible, I have attached a script to generate a huge rect() plot, as big as the ones I'm using on my web.
> >
> > The problem I reffer to is the sligth dealy and plot-freeze when one of the rectangles is clicked. Is there any way to avoid it?
> >
> > Find attached the code to generate the aforementioned plot
> > import numpy as np
> > import pandas as pd
> > from bokeh.plotting import figure, show, reset_output
> > from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
> > from bokeh.transform import transform
> >
> > size = 500
> >
> > #Creating random data to fill heatmap
> > df = pd.DataFrame(np.random.randint(0,100,size=((size**2), 4)), columns=list('ABCD'))
> > df['Y'] = list(range(1,size+1))*size
> > df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
> > print(df)
> > # Mapper
> > colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
> > colors.reverse()
> > mapper = LinearColorMapper(palette=colors, low=0, high=100)
> >
> > p = figure(
> > width = 10000,
> > height = 10000,
> > tools=["hover","tap","save","reset","wheel_zoom"],
> > x_axis_location="above",
> > active_drag=None,
> > toolbar_location="right",
> > toolbar_sticky = False,
> > )
> >
> > # Create rectangle for heatmap
> > mysource = ColumnDataSource(df)
> > p.rect(
> > y="Y",
> > x="X",
> > width=1,
> > height=1,
> > source=mysource,
> > line_color="white",
> > fill_color=transform("C", mapper),
> >
> > # set visual properties for selected glyphs
> > selection_line_color="black",
> > selection_fill_color=transform("C", mapper),
> > # set visual properties for non-selected glyphs
> > nonselection_fill_color=transform("C", mapper),
> > nonselection_fill_alpha=1,
> > nonselection_line_alpha=1,
> > nonselection_line_color="white"
> > )
> > show(p)
> > reset_output()
> >
> >
> >
> >
> > El martes, 14 de mayo de 2019, 17:22:09 (UTC+2), Bryan Van de Ven escribió:
> > I can't seem to reproduce any issue with Bokeh 1.1.0 so the first best thing to try is updating your Bokeh version from 0.13.
> >
> > Thanks,
> >
> > Bryan
> >
> > > On May 14, 2019, at 6:30 AM, [email protected] <[email protected]> wrote:
> > >
> > > I have created a huge heatmap-like plot using the rect() glyph. For this plot, I intend to perform some actions when one of the rectangle elements is clicked. Unfortunately, when clicked, the whole plot freezes for a couple of seconds before performing the desired actions. It may seem meaningless, but on our web it causes the impression that it has freezed
> > >
> > > Is there some way to avoid this small delay in a rec() glyph?
> > >
> > > Please, find an example heatmap-like plot attached to this message, as well as the code used to compute it.
> > > import numpy as np
> > > import pandas as pd
> > > from bokeh.plotting import figure, show, reset_output
> > > from bokeh.models import ColumnDataSource, LinearColorMapper, Range1d
> > > from bokeh.transform import transform
> > >
> > > size = 150
> > >
> > > #Creating random data to fill heatmap
> > > df = pd.DataFrame(np.random.randint(0,size,size=((size**2), 4)), columns=list('ABCD'))
> > > df['Y'] = list(range(1,size+1))*size
> > > df['X'] = list(np.repeat(np.array(list(range(1,size+1))), size, axis=0))
> > >
> > > # Mapper
> > > colors = ['#FF0000','#FF0800','#FF1000','#FF1800','#FF2000','#FF2800','#FF3000','#FF3800','#FF4000','#FF4800','#FF5000','#FF5900','#FF6100','#FF6900','#FF7100','#FF7900','#FF8100','#FF8900','#FF9100','#FF9900','#FFA100','#FFAA00','#FFB200','#FFBA00','#FFC200','#FFCA00','#FFD200','#FFDA00','#FFE200','#FFEA00','#FFF200','#FFFA00','#FAFF00','#F2FF00','#EAFF00','#E2FF00','#DAFF00','#D2FF00','#CAFF00','#C2FF00','#BAFF00','#B2FF00','#AAFF00','#A1FF00','#99FF00','#91FF00','#89FF00','#81FF00','#79FF00','#71FF00','#69FF00','#61FF00','#59FF00','#50FF00','#48FF00','#40FF00','#38FF00','#30FF00','#28FF00','#20FF00','#18FF00','#10FF00','#08FF00','#00FF00']
> > > colors.reverse()
> > > mapper = LinearColorMapper(palette=colors, low=0, high=100)
> > >
> > > p = figure(
> > > width = 1000,
> > > height = 1000,
> > > tools=["hover","tap","save","reset","wheel_zoom"],
> > > x_axis_location="above",
> > > active_drag=None,
> > > toolbar_location="right",
> > > toolbar_sticky = False,
> > > )
> > >
> > > # Create rectangle for heatmap
> > > mysource = ColumnDataSource(df)
> > > p.rect(
> > > y="Y",
> > > x="X",
> > > width=1,
> > > height=1,
> > > source=mysource,
> > > line_color="white",
> > > fill_color=transform("C", mapper),
> > >
> > > # set visual properties for selected glyphs
> > > selection_line_color="black",
> > > selection_fill_color=transform("C", mapper),
> > > # set visual properties for non-selected glyphs
> > > nonselection_fill_color=transform("C", mapper),
> > > nonselection_fill_alpha=1,
> > > nonselection_line_alpha=1,
> > > nonselection_line_color="white"
> > > )
> > > show(p)
> > > reset_output()
> > >
> > >
> > >
> > > --
> > > 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/55715bfa-3300-46cc-884f-2956032146a1%40continuum.io.
> > > For more options, visit https://groups.google.com/a/continuum.io/d/optout.
> > > <heatmap_plot.html>
> >
> >
> > --
> > 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/7e29da75-f57c-4517-9687-b6eceb61be90%40continuum.io.
> > For more options, visit https://groups.google.com/a/continuum.io/d/optout.
>
>
> --
> 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/71dde2bd-0868-4903-87a3-7922872aa0cc%40continuum.io.
> For more options, visit https://groups.google.com/a/continuum.io/d/optout.

--
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/ed685196-0000-4f2e-a669-c8700b533628%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.