Selecting image glyps

Hello,

I am trying to follow the example here with selecting/ unselecting glyphs and applying it image glyphs. I am using image_url, which works btw, but the selection doesn’t. Here is the code snippet,

///

from bokeh.plotting import figure, show, output_file

from bokeh.models.glyphs import ImageURL

from bokeh.models import Plot

output_file(‘testBokeh.html’)

urls = [‘images/testImage.png’] * 9

x = [1, 2, 3, 4, 5, 6, 7, 8, 9]

plot = figure(x_range=(0,10), y_range=(0,10), plot_width=512, plot_height=512)

renderer = plot.image_url(urls, x, x, w=0.5, h=0.5, anchor=“bottom_left”)

selected_glyph = ImageURL(url=‘images/testImage.png’, x=0, y=0, w=0.5, h=0.5, anchor=“bottom_left”, global_alpha=0.5)

nonselected_glyph = ImageURL(url=‘images/testImage.png’, x=0, y=0, w=0.5, h=0.5, anchor=“bottom_left”, global_alpha=0.2)

renderer.selection_glyph = selected_glyph

renderer.nonselection_glyph = nonselected_glyph

show(plot)

///

Any ideas what I may be doing wrong?

Thanks!

Hi,

Hit testing support is not uniform across all glyphs. (The details are outlined somewhere in the docs although I was not able to find it just now at a glance.) ImageURL does not currently support any hit testing at all. It might not be too difficult to add rudimentary brute-force hit testing of all of the image bounding boxes. I'm not sure if that's useful or not, I'd encourage you to open a GitHub issue to discuss the feature request more.

Bryan

···

On Jun 6, 2017, at 19:49, [email protected] wrote:

Hello,

I am trying to follow the example here with selecting/ unselecting glyphs and applying it image glyphs. I am using image_url, which works btw, but the selection doesn't. Here is the code snippet,

///

from bokeh.plotting import figure, show, output_file
from bokeh.models.glyphs import ImageURL
from bokeh.models import Plot

output_file('testBokeh.html')

urls = ['images/testImage.png'] * 9
x = [1, 2, 3, 4, 5, 6, 7, 8, 9]

plot = figure(x_range=(0,10), y_range=(0,10), plot_width=512, plot_height=512)
renderer = plot.image_url(urls, x, x, w=0.5, h=0.5, anchor="bottom_left")

selected_glyph = ImageURL(url='images/testImage.png', x=0, y=0, w=0.5, h=0.5, anchor="bottom_left", global_alpha=0.5)
nonselected_glyph = ImageURL(url='images/testImage.png', x=0, y=0, w=0.5, h=0.5, anchor="bottom_left", global_alpha=0.2)

renderer.selection_glyph = selected_glyph
renderer.nonselection_glyph = nonselected_glyph

show(plot)

///

Any ideas what I may be doing wrong?

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/bdfa65c6-d493-4370-ac49-5d58f5b0420c%40continuum.io\.
For more options, visit https://groups.google.com/a/continuum.io/d/optout\.

Thanks for the quick reply, Bryan! I think testing against the bounding boxes should resolve the issue. I will check out how to create a github issue, as this is my first post here.

In the meanwhile, I am thinking about adding squares around the images (with alpha = 0) for my purposes. That should achieve what I am trying to do. Need to try that out.

-Siddharth

···

On Tuesday, June 6, 2017 at 8:09:55 PM UTC-5, Bryan Van de ven wrote:

Hi,

Hit testing support is not uniform across all glyphs. (The details are outlined somewhere in the docs although I was not able to find it just now at a glance.) ImageURL does not currently support any hit testing at all. It might not be too difficult to add rudimentary brute-force hit testing of all of the image bounding boxes. I’m not sure if that’s useful or not, I’d encourage you to open a GitHub issue to discuss the feature request more.

Bryan

On Jun 6, 2017, at 19:49, [email protected] wrote:

Hello,

I am trying to follow the example here with selecting/ unselecting glyphs and applying it image glyphs. I am using image_url, which works btw, but the selection doesn’t. Here is the code snippet,

///

from bokeh.plotting import figure, show, output_file

from bokeh.models.glyphs import ImageURL

from bokeh.models import Plot

output_file(‘testBokeh.html’)

urls = [‘images/testImage.png’] * 9

x = [1, 2, 3, 4, 5, 6, 7, 8, 9]

plot = figure(x_range=(0,10), y_range=(0,10), plot_width=512, plot_height=512)

renderer = plot.image_url(urls, x, x, w=0.5, h=0.5, anchor=“bottom_left”)

selected_glyph = ImageURL(url=‘images/testImage.png’, x=0, y=0, w=0.5, h=0.5, anchor=“bottom_left”, global_alpha=0.5)

nonselected_glyph = ImageURL(url=‘images/testImage.png’, x=0, y=0, w=0.5, h=0.5, anchor=“bottom_left”, global_alpha=0.2)

renderer.selection_glyph = selected_glyph

renderer.nonselection_glyph = nonselected_glyph

show(plot)

///

Any ideas what I may be doing wrong?

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/bdfa65c6-d493-4370-ac49-5d58f5b0420c%40continuum.io.

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