仅在Python散景中显示一个字形的悬停工具提示 [英] Only show Hover Tooltip for One Glyph in Python bokeh

查看:75
本文介绍了仅在Python散景中显示一个字形的悬停工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想拥有我的悬停工具,仅当我将悬停在菱形上方时才显示.如您所见,我的情节包含菱形和线条.

I want to have my hovertool, showing only when I hover above the diamonds. As you will see my plot contains diamonds and lines.

tooltips = [("Year", "@x{0}"), ("Numbers", "@y{0}")]
p = figure(plot_width=800, plot_height=400,tooltips=tooltips)
p.diamond(df3reset["Years"], df3reset["Numbers"], size=20,
color="navy", alpha=0.5)
p.line(df3reset["Years"], df3reset["Numbers"], line_width=2)
p.xaxis.axis_label = 'Year'
p.yaxis.axis_label = 'Number of dogs'
show(p)

我不希望悬停工具仅在将鼠标悬停在菱形上时才在行中显示信息,解决方案是什么?

I dont want the hovertool to show the information on the line only while hovering over the diamonds, what would be the solution?

问候

推荐答案

然后从figure删除tooltips,然后:

diamonds = p.diamond(df3reset["Years"], df3reset["Numbers"], size=20, color="navy", alpha=0.5)
p.add_tools(HoverTool(tooltips=tooltips, renderers=[diamonds]))

这篇关于仅在Python散景中显示一个字形的悬停工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆