Python Bokeh Hover Tool给出:AttributeError:图中的意外属性'工具提示'

Fir*_*047 0 python bokeh

如何在Bokeh 0.12.11(以及可能的其他版本)中为悬停工具实现"工具提示"?

搜索"Bokeh hover工具提示"提供了大量文档结果,例如:https: //bokeh.pydata.org/en/latest/docs/user_guide/tools.html

但是,当我尝试通过以下示例实现Bokeh 0.12.11上的"工具提示"时:https://bokeh.pydata.org/en/latest/docs/gallery/elements.html

我收到以下错误: AttributeError: unexpected attribute 'tooltips' to Figure, possible attributes are above, aspect_scale, etc.

Fir*_*047 6

解:

我删除了TOOLTIP = []声明,以及figure()对象中的tooltips =参数.

以编程方式创建悬停工具并附加到图:

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)
Run Code Online (Sandbox Code Playgroud)

正如在此指出的: Python Bokeh HoverTool格式化程序错误:"HoverTool的意外属性'格式化程序'"

版本0.12.11支持它,但我在实现它时遇到了麻烦.

感谢bigreddot指出传递该参数仅适用于0.13.