Another possibility is to configure the glyphs with arbitrary name
values (you can specify whatever names you want) and then you can query for thing that match that name:
In [8]: p = figure()
In [9]: p.circle()
Out[9]: GlyphRenderer(id='1036', ...)
In [10]: p.circle(name="foo")
Out[10]: GlyphRenderer(id='1041', ...)
In [11]: p.select(name="foo")
Out[11]: [GlyphRenderer(id='1041', ...)]
FYI you can also query by type or other criteria.
There is also a similar select
on the BokehJS side (it’s not clear if you mean to get the the renderers in Python or JS code).
If for some reason setting name
is not convenient (e.g. if you are already relying @name
in hover tooltips) then on the Python side there is an even more general querying facility in bokeh.core.query
(it gets very little attention, but has been around and maintained forever)