如何在不显示悬停工具提示的情况下触发悬停的视觉效果

How to trigger visual effects of hover without showing a hover tooltip

我有一个很大的热图,其中我通过 p.image 绘制单元格,悬停显示精确值。 此外,当鼠标悬停在一个区域上时,该区域应该用轮廓突出显示。只有 hover_outline_alpha=1p.rect 完全符合我的要求,但它还显示悬停工具提示。有什么方法可以在仍然触发视觉变化的同时禁用悬停工具提示吗?

from bokeh.palettes import Viridis256
from bokeh.models import HoverTool
from bokeh.plotting import figure

image = [np.array([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 0, 1], [0, 0, 1, 0]])]
p = figure(x_range=["aa", "ab", "ba", "bb"], y_range=["aa", "ab", "ba", "bb"], 
           tooltips=[("x", "$x"), ("y", "$y"), ("value", "@image")])

# heatmap 
image_renderer = p.image(image=image, x=0, y=0, dw=4, dh=4, palette=Viridis256)

# outlines for each region
rect_renderer = p.rect(x=[1, 1, 3, 3], y=[1, 3, 1, 3], width=2, height=2, 
       fill_alpha=0.0, line_alpha=0.0, hover_line_alpha=1, line_width=3)


# Disables the tooltip on rect_renderer, but also does not trigger the outline
p.hover.renderers = [image_renderer]
# Seperate hover triggers the hover, but also shows an empty tooltip.
p.add_tools(HoverTool(renderers=[rect_renderer], tooltips=""))

show(p)

cross posted 这个问题发到 bokeh discourseforum 和 bryan 回答:

Set toolips=None, not the empty string. This is documented at the bottom of the reference guide entry for tooltips:

None is also a valid value for tooltips. This turns off the rendering of tooltips.