Reputation: 81
How do I implement "tooltips" for the hover tool in Bokeh 0.12.11 (and possibly other versions)?
Searching for "Bokeh hover tooltips" gives a bunch of documentation results such as: https://docs.bokeh.org/en/latest/docs/user_guide/tools.html
But when I try to implement the "tooltips" on Bokeh 0.12.11 from an example such as: https://docs.bokeh.org/en/latest/docs/gallery/elements.html
I get the following error:
AttributeError: unexpected attribute 'tooltips' to Figure, possible attributes are above, aspect_scale, etc.
Upvotes: 0
Views: 6170
Reputation: 81
Solution:
I removed the TOOLTIP= [] declaration, and the tooltips= parameter in the figure() object.
Make the Hover Tool programatically and attach to Figure:
from bokeh.models import HoverTool
{ some code }
p = figure(tools=TOOLS, title=TITLE, x_axis_label='Pressure (mTorr)', y_axis_label='Roughness (nm)')
hover = HoverTool()
hover.tooltips = [
("Sample", "@names"),
("Pressure", "@x_values mTorr"),
("Roughness", "@y_values nm"),
]
p.tools.append(hover)
As pointed out here: Python Bokeh HoverTool formatters error: "unexpected attribute 'formatters' to HoverTool"
version 0.12.11 supports it but I was having trouble implementing it.
Thanks to bigreddot for pointing out that passing that parameter only works in 0.13.
Upvotes: 7