Why was the "names" attribute removed from HoverTool

So I’ve decided to upgrade from Bokeh 2.4.2 to 3.2.1 so that I could use the “anchor” param when calling plot.image_rgba(). That’s all working but now when I create hover tools I noticed it complains because the ‘names’ attribute is no longer around. I was wondering if there’s an equivalent alternative or why it was removed if anybody has insight?

For example, I used to be able to run:

p = figure()
p.line(x1, y1, name='xy')
p.line(x2, y2, name='xy')
p.line(a, b)
# This would only apply to the first two p.line calls
hover = HoverTool(names=['xy'])

but now as far as I know I need to pass each renderer to the HoverTool call in order to get the equivalent “selective hover”. Which isn’t horrible I just have to keep track of all renderers now and divide them up to achieve the same as an extra parameter to the plotting call

p = figure()
line1 = p.line(x1, y1, name='xy')
line2 = p.line(x2, y2, name='xy')
p.line(a, b)
# This would only apply to the first line call
hover = HoverTool(renderers=[line1, line2])

Computing renderers from names was an error-prone source of bugs and leaks, and it was also underspecified and inconsistent in its specification (when should names results be computed? Only at model init? On names property updates? What if a new glyph with the same name was added later?) [1]

Note that the deprecation was documented in the docstring as well as the 2.3.0 release notes:

DataRange.names, SelectTool.names and HoverTool.names were deprecated
and will be removed in bokeh 3.0. Use respective renderers properties instead,
possibly in combination with plot.select(name="renderer name").


  1. TLDR same story as with any OSS project: it was a complexity burden that a small volunteer team was no longer willing to maintain. ↩︎

gotcha, thanks for the quick reply! I’ll get used to using renderers

:+1: note that plot.select(name="renderer name") should get you a list of renderers that have the given name value, at the moment select is called.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.