我有一个大的热图,其中我通过p.image
绘制单元,并用鼠标悬停显示精确的值。
此外,当鼠标悬停在某个区域上时,该区域应以轮廓突出显示。只有hover_outline_alpha=1
的p.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)
我向博克语篇论坛提出这个问题,布莱恩回答:
相关问题 更多 >
编程相关推荐