Assign names to each patch of patches

As I understand it, you can add a name to a patch:

p.patch([1,2,3,4], [1,2,3,4], name=‘single_patch’)

and you can add a name to a patches object:

p.patches([[1,2,3,4], [1,2,3,4],], [[6,7,8,9], [6,7,8,9]], name=‘list_of_patches’)

However, is there a way to name each patch of a list of patches?

p.patches([[1,2,3,4], [1,2,3,4],], [[6,7,8,9], [6,7,8,9]], name=[‘first_patch’, ‘second_patch’])

The use case is that is makes selecting individual patches easier. So, in the case of a USA county map, I can name each patch according to its county name and then when I need to update some information for a given county then I can select for it directly.

Sean,

No, the name is actually attached to the glyph renderer, and the main purpose is to make finding the glyph renderer simple (e.g. with .select() or .select_one() functions) so that its properties can be modified.

For this use case I'd suggest making a mapping of the names you want to the indices in a python dict. If you need to use it in a CustomJS callback, then you can do something like:

    code = """

    var counties_index = %s;

    """ % my_mapping_dict

which to easily get the mapping into JS (just like Sarah used on the original non-app version of the Gapminder example).

Thanks,

Bryan

···

On Aug 26, 2016, at 10:36 AM, [email protected] wrote:

As I understand it, you can add a name to a patch:

p.patch([1,2,3,4], [1,2,3,4], name='single_patch')

and you can add a name to a patches object:

p.patches([[1,2,3,4], [1,2,3,4],], [[6,7,8,9], [6,7,8,9]], name='list_of_patches')

However, is there a way to name each patch of a list of patches?

p.patches([[1,2,3,4], [1,2,3,4],], [[6,7,8,9], [6,7,8,9]], name=['first_patch', 'second_patch'])

The use case is that is makes selecting individual patches easier. So, in the case of a USA county map, I can name each patch according to its county name and then when I need to update some information for a given county then I can select for it directly.

--
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/301a5a51-098e-4195-a0c3-650896229452%40continuum.io.
For more options, visit https://groups.google.com/a/continuum.io/d/optout.

Thanks, Bryan. I'll try that!