0

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.

7
  • 3
    Although self-answering your questions are welcome here, please provide your solution as an answer to your question. With that said, what exactly is your question anyways? Commented Jul 19, 2018 at 2:32
  • 3
    If you have a good question that has no answer here you can ask and answer your own question, but you shouldn't answer IN the question Commented Jul 19, 2018 at 2:38
  • Apologies for not posing a proper question, I guess it was implied in the preamble. Commented Jul 19, 2018 at 2:57
  • 1
    Can you do it this time? As a maintainer of Bokeh, having unanswered questions on SO is actually a burden for me and others. It will only take you a few moments to post a proper answer, and it will help other users. Commented Jul 19, 2018 at 4:44
  • 1
    Tho I should add, your conclusion is not quite right. The error you are seeing about tooltips and Figure is because the ability to pass tooltips to Figure was added in 0.13 but you are running 0.12.11. You should always refer to the documentation and examples for the version you are actually running, if it is not the latest. Commented Jul 19, 2018 at 5:14

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.