如何在Bokeh 0.12.11(以及可能的其他版本)中为悬停工具实现“工具提示”?
搜索“散景悬停工具提示”会给出一系列文档结果,例如: 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.
答案 0 :(得分:5)
解决方案:
我删除了Figure()对象中的TOOLTIP = []声明和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)
在这里指出: Python Bokeh HoverTool formatters error: "unexpected attribute 'formatters' to HoverTool"
版本0.12.11支持它,但是我在实现它时遇到了麻烦。
感谢bigreddot指出,传递该参数仅在0.13中有效。