python - 如何仅在散景多线图中仅显示行光标打开的悬停工具提示?
问题描述
因此,我绘制并显示了各种行的悬停工具提示,如下所示:
def plotter(results, title):
results = results.rename(columns = dict(zip(results.columns, [col.strip().replace(' ','_') for col in results.columns])))
source = ColumnDataSource(results)
p = figure(plot_width=600, plot_height=300)
for color, col in enumerate(results.columns):
glyph = Circle(x='month', y=col,
#source=source,
size=3, line_color=Turbo256[color*5], fill_color = Turbo256[color*5])
p.add_glyph(source, glyph)
p.line(x='month', y = col, source = source, color = Turbo256[color*5], line_width = 1)
p.title.text = f"Monthly rates trends Based on {title.replace('_',' ').title()} "
p.xaxis.axis_label = 'Months'
p.yaxis.axis_label = 'Rates'
hover=HoverTool(show_arrow=False, line_policy='next', tooltips = [
(col.replace('_',' ').title(), f'@{col}') for col in results.columns] )
p.add_tools(hover)
show(p)
虽然这很好用,但每当我将一个点悬停在图表上时,它都会显示每条线的工具提示。我不想显示所有的工具提示。我只希望这些工具提示显示当前所在的光标。就像它在一行上只有一个关于该行的工具提示应该显示,如果它在有两行的某个点上,它可能会显示两个的工具提示,依此类推。我一直在尝试使用CustomJS
,但还没有想出办法。任何有关这方面的帮助都将非常有帮助。
解决方案
推荐阅读
- javascript - 如何重用函数属性?
- php - 如何在容器中安装 WordPress + php-fpm 并在花药容器中安装 nginx 并连接它们
- facebook - 如果我的转化 API 是通过合作伙伴设置的,如何向我的 Facebook Pixel 发送事件 ID?
- json - 无法解析返回 NULL 的 JSON
- jquery - WebSocket 不会在消息上附加 HTML
- jenkins - 为publish-over-dropbox jenkins插件创建凭据时出错
- sql - 为什么我收到 ORA-00979: not a GROUP BY 表达式错误
- c# - HttpWebRequest 将 SSL .Key-File 添加到 WebRequest
- flask - 我应该在 Flask 缓存或会话中存储数据帧吗?
- excel - 如何使用单元格引用另一个工作表名称值?