selection_glyph is not defined when adding glyphs to figures

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

···

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%40continuum.io.

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

Hi Sarah,

Thanks a lot for the quick reply! I actually saw your awesome talk on Youtube and I’ve been looking through that code. I’m having some troubles passing the adequate parameters to Plot (it doesn’t display my map at all, maybe I’m setting the x and y ranges incorrectly), that’s why I was using figure() instead.

Best,

Alonso

···

On Thursday, June 4, 2015 at 3:30:33 PM UTC-4, Sarah Bird wrote:

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%40continuum.io.

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

Feel free to post some code, maybe in a notebook, and we can take a look?

···

On Thu, Jun 4, 2015 at 10:13 PM, Alonso Patron [email protected] wrote:

Hi Sarah,

Thanks a lot for the quick reply! I actually saw your awesome talk on Youtube and I’ve been looking through that code. I’m having some troubles passing the adequate parameters to Plot (it doesn’t display my map at all, maybe I’m setting the x and y ranges incorrectly), that’s why I was using figure() instead.

Best,

Alonso

On Thursday, June 4, 2015 at 3:30:33 PM UTC-4, Sarah Bird wrote:

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%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/5803f8f4-462f-4b55-9421-ba2f08f786b8%40continuum.io.

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

One random note if you’re looking at my code from the pycon talk is that there was a backwards-incompatible change from 0.8.2 to 0.9 regarding selections, so my pycon code won’t work on 0.9.

···

On Thu, Jun 4, 2015 at 10:15 PM, Sarah Bird [email protected] wrote:

Feel free to post some code, maybe in a notebook, and we can take a look?

On Thu, Jun 4, 2015 at 10:13 PM, Alonso Patron [email protected] wrote:

Hi Sarah,

Thanks a lot for the quick reply! I actually saw your awesome talk on Youtube and I’ve been looking through that code. I’m having some troubles passing the adequate parameters to Plot (it doesn’t display my map at all, maybe I’m setting the x and y ranges incorrectly), that’s why I was using figure() instead.

Best,

Alonso

On Thursday, June 4, 2015 at 3:30:33 PM UTC-4, Sarah Bird wrote:

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%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/5803f8f4-462f-4b55-9421-ba2f08f786b8%40continuum.io.

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

Ah good to know, I’m working with 0.9.

···

On Thursday, June 4, 2015 at 4:19:59 PM UTC-4, Sarah Bird wrote:

One random note if you’re looking at my code from the pycon talk is that there was a backwards-incompatible change from 0.8.2 to 0.9 regarding selections, so my pycon code won’t work on 0.9.

On Thu, Jun 4, 2015 at 10:15 PM, Sarah Bird [email protected] wrote:

Feel free to post some code, maybe in a notebook, and we can take a look?

On Thu, Jun 4, 2015 at 10:13 PM, Alonso Patron [email protected] wrote:

Hi Sarah,

Thanks a lot for the quick reply! I actually saw your awesome talk on Youtube and I’ve been looking through that code. I’m having some troubles passing the adequate parameters to Plot (it doesn’t display my map at all, maybe I’m setting the x and y ranges incorrectly), that’s why I was using figure() instead.

Best,

Alonso

On Thursday, June 4, 2015 at 3:30:33 PM UTC-4, Sarah Bird wrote:

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%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/5803f8f4-462f-4b55-9421-ba2f08f786b8%40continuum.io.

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

I am remaking the map for 0.9 though and if you want to see an example of: a map, in bokeh 0.9, with a slider, without the server see - http://nbviewer.ipython.org/github/birdsarah/cge-tools/blob/share_interactive_map/interactive_map/Map%20with%20time%20slider.ipynb

(this doesn’t have selection but I would do it the same as I previously mentioned)

···

On Thu, Jun 4, 2015 at 10:29 PM, Alonso Patron [email protected] wrote:

Ah good to know, I’m working with 0.9.

On Thursday, June 4, 2015 at 4:19:59 PM UTC-4, Sarah Bird wrote:

One random note if you’re looking at my code from the pycon talk is that there was a backwards-incompatible change from 0.8.2 to 0.9 regarding selections, so my pycon code won’t work on 0.9.

On Thu, Jun 4, 2015 at 10:15 PM, Sarah Bird [email protected] wrote:

Feel free to post some code, maybe in a notebook, and we can take a look?

On Thu, Jun 4, 2015 at 10:13 PM, Alonso Patron [email protected] wrote:

Hi Sarah,

Thanks a lot for the quick reply! I actually saw your awesome talk on Youtube and I’ve been looking through that code. I’m having some troubles passing the adequate parameters to Plot (it doesn’t display my map at all, maybe I’m setting the x and y ranges incorrectly), that’s why I was using figure() instead.

Best,

Alonso

On Thursday, June 4, 2015 at 3:30:33 PM UTC-4, Sarah Bird wrote:

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%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/5803f8f4-462f-4b55-9421-ba2f08f786b8%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/526b634a-ea69-4fce-908a-2a991fb955e8%40continuum.io.

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

Thanks a lot for the help Sarah! I’m now able to format the display properties of my selected patches. I’m still having problems displaying the map with the correct aspect ratio but that’s probably a bug in my code. Thanks again.

A

···

On Thursday, June 4, 2015 at 5:29:32 PM UTC-4, Sarah Bird wrote:

I am remaking the map for 0.9 though and if you want to see an example of: a map, in bokeh 0.9, with a slider, without the server see - http://nbviewer.ipython.org/github/birdsarah/cge-tools/blob/share_interactive_map/interactive_map/Map%20with%20time%20slider.ipynb

(this doesn’t have selection but I would do it the same as I previously mentioned)

On Thu, Jun 4, 2015 at 10:29 PM, Alonso Patron [email protected] wrote:

Ah good to know, I’m working with 0.9.

On Thursday, June 4, 2015 at 4:19:59 PM UTC-4, Sarah Bird wrote:

One random note if you’re looking at my code from the pycon talk is that there was a backwards-incompatible change from 0.8.2 to 0.9 regarding selections, so my pycon code won’t work on 0.9.

On Thu, Jun 4, 2015 at 10:15 PM, Sarah Bird [email protected] wrote:

Feel free to post some code, maybe in a notebook, and we can take a look?

On Thu, Jun 4, 2015 at 10:13 PM, Alonso Patron [email protected] wrote:

Hi Sarah,

Thanks a lot for the quick reply! I actually saw your awesome talk on Youtube and I’ve been looking through that code. I’m having some troubles passing the adequate parameters to Plot (it doesn’t display my map at all, maybe I’m setting the x and y ranges incorrectly), that’s why I was using figure() instead.

Best,

Alonso

On Thursday, June 4, 2015 at 3:30:33 PM UTC-4, Sarah Bird wrote:

Hi Alonso,

I’m not so great with the plotting interface, but I can tell you how to do this using the low-level interface in case that’s any help.

See: http://nbviewer.ipython.org/github/birdsarah/pycon_2015_bokeh_talk/blob/master/notebooks/Building%20the%20static%20visualization.ipynb#Make-selection-style-correctly

countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color="#FFFFFF",
)

selected_countries = Patches(
    xs='xs',
    ys='ys',
    fill_color='wat_color',
    line_color=ORANGE,
    line_width=5,
)

map_box = Plot(.....)
map_box.add_glyph(ColumnDataSource(data), countries, selection_glyph=selected_countries, nonselection_glyph=countries)
map_box.add_tools(TapTool())

Hope this helps.

Sarah Bird

On Thu, Jun 4, 2015 at 9:17 PM, Alonso Patron [email protected] wrote:

Hi,

I’m trying to change the appearance of a patch when it’s selected with the TapTool. I’m creating a figure and adding some patches like:

p = figure(some_args)

p.patches(‘xs’,‘ys’, source=source, name=“my patches”)

glyph = p.select(name=“mypatches”)[0].selection_glyph

glyph.line_color = “blue”

But the glyph that it’s returned is NoneType. Checking the code inside _glyph_function it seems that only the glyph and nonselection_glyph member variables of the GlyphRenderer are initialized.

I just started using Bokeh, is this the correct way if editing the appearance of glyphs for tap events? Thanks a lot for your help and for creating such a great library!

Best,

Alonso

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/ab524ad1-5105-4387-95d9-c6c99f19dcff%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/5803f8f4-462f-4b55-9421-ba2f08f786b8%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/526b634a-ea69-4fce-908a-2a991fb955e8%40continuum.io.

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