本文介绍了Python Bokeh Hover Tool提供了:AttributeError:图的意外属性"tooltips"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

搜索散景悬停工具提示"会给出一系列文档结果,例如: https://docs.bokeh.org/en/latest/docs/user_guide/tools.html

Searching for "Bokeh hover tooltips" gives a bunch of documentation results such as:https://docs.bokeh.org/en/latest/docs/user_guide/tools.html

但是,当我尝试通过以下示例在Bokeh 0.12.11上实现工具提示"时: https://docs.bokeh.org/en/latest/docs/gallery/elements.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

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

推荐答案

解决方案:

我删除了Figure()对象中的TOOLTIP = []声明和tooltips =参数.

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)

如此处所指出: Python Bokeh HoverTool formatters错误:意外属性'formatters 到HoverTool""

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

version 0.12.11 supports it but I was having trouble implementing it.

感谢bigreddot指出,传递该参数仅在0.13中有效.

Thanks to bigreddot for pointing out that passing that parameter only works in 0.13.

这篇关于Python Bokeh Hover Tool提供了:AttributeError:图的意外属性"tooltips"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-29 04:47