python - Python Bokeh 悬停工具给出:AttributeError:意外属性“工具提示”到图
问题描述
如何在 Bokeh 0.12.11(可能还有其他版本)中为悬停工具实现“工具提示”?
搜索“散景悬停工具提示”会得到一堆文档结果,例如: 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
我收到以下错误:
AttributeError: unexpected attribute 'tooltips' to Figure, possible attributes are above, aspect_scale, etc.
解决方案
解决方案:
我删除了 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)
正如这里所指出的: Python Bokeh HoverTool formatters error: "unexpected attribute 'formatters' to HoverTool"
0.12.11 版支持它,但我在实现它时遇到了麻烦。
感谢 bigreddot 指出传递该参数仅适用于 0.13。
推荐阅读
- r - 如何在函数中定义可选参数
- django - 无法使用 Minikube + ingress + Django 路由流量
- racket - 球拍 - 定义结构和抽象列表功能
- google-apps-script - 是否可以更新现有的数据验证帮助文本?
- json - 在逻辑应用程序 JSON 数组中解析单个对象的抛出错误但对于多个对象它工作正常
- json - 'Int' 不能转换为 'CGFloat' SwiftUI 误导性错误
- android - 我很困惑android中的ffmpeg文件是什么
- python - 处理pandas groupby中的项目很慢?我们应该使用哈希图吗?
- java - JavaFX中如何让TableView根据其内容自动改变高度?
- python - Discord.py 检查 Channel 是否为 DM