2

I used jupyter notebook to do a practice of visualization, then I followed the code on http://docs.bokeh.org/en/latest/docs/user_guide/tools.html#basic-tooltips

the code on the website

It works, so I tried to add the "Formatting Tooltip", like the below code.

I just only added the attribute 'formatters', but the error happened.

from bokeh.plotting import figure, ColumnDataSource
from bokeh.models import HoverTool
from bokeh.io import output_notebook, show

output_notebook()

source = ColumnDataSource(data=dict(
    x=[1, 2, 3, 4, 5],
    y=[2, 5, 8, 2, 7],
    desc=['A', 'b', 'C', 'd', 'E'],
))

hover = HoverTool(
        tooltips=[
            ("index", "$index"),
            ("(x,y)", "($x, $y)"),
            ("desc", "@desc"),
        ],
        formatters={
            'desc' : 'printf', # use 'datetime' formatter for 'date' field
                               # use default 'numeral' formatter for other fields
        }
    )

p = figure(plot_width=400, plot_height=400, tools=[hover],
           title="Mouse over the dots")

p.circle('x', 'y', size=20, source=source)

the error message:

AttributeError: unexpected attribute 'formatters' to HoverTool, possible attributes are anchor, attachment, callback, js_callbacks, line_policy, mode, name, names, plot, point_policy, renderers, show_arrow, tags or tooltips
3
  • I remember having a similar issue once, and the problem was that I was following the latest documentation but using a slightly older bokeh. Try first by updating your bokeh package to the latest one. Commented Aug 24, 2017 at 8:01
  • OK, let's me check. Thanks Commented Aug 24, 2017 at 9:28
  • @IgnacioVergaraKausel you are right. I'm using the older bokeh 0.12.4. After updating the package, I solve the problem. Thank you very much. Commented Aug 25, 2017 at 2:19

1 Answer 1

4

The above comment is certainly correct. The .formatters property for HoverTool was only added recently in PR #6183, which was part of the 0.12.6 release. You will need to have at least Bokeh 0.12.6 or newer installed to use it.


Bokeh is still adding new features, so if you do not have the latest version of Bokeh installed, it is important to reference the docs for the version you actually have installed, e.g.

http://docs.bokeh.org/en/0.12.5/

Provides docs specifically for version 0.12.5. Additionally you can always obtain the example code specific to your installed version from CDN. Again for version 0.12.5 there is:

https://cdn.bokeh.org/bokeh/examples/examples-0.12.5.zip

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

1 Comment

Yes, the problem happen because of the older version. After updating to 0.12.6, the problem had fixed. Thanks.

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.