Python/Bokeh: Disable hover tool for hidden glyphs (via interactive legend)

走远了吗. 提交于 2020-01-24 20:50:09

问题


Problem description

Since bokeh 0.12.5 it is possible to use interactive legends to hide or mute glyphs via clicking on them in the legend box. This is a great feature especially for more complex plots.

However, when used in conjunction with the hover tool, hidden glyphs should not trigger the hover tool because the user is provided with a tooltip for glyphs which are not visible (due to muting via the interactive legend).

Here is minimal code example for clarification:

import numpy as np
from bokeh.plotting import figure, show, output_notebook

x = np.arange(0, 10, 1)

p = figure(tools=["hover"])
p.line(x, x, legend="Line 1")
p.line(x, x/2, legend="Line 2")

p.legend.click_policy = "hide"
show(p)

This is the resulting plot (without hiding):

This is the plot with Line 2 being hidden but having an active hover tooltip:

Question

Is there an option I'm currently missing to deactivate hover tooltips for hidden glyphs? If not, does anyone can think of a short workaround (perhaps employing CustomCS)?

Thanks!


回答1:


As of bokeh 0.12.6, it is fixed. For more, see the issue in the github repo here.



来源:https://stackoverflow.com/questions/44408571/python-bokeh-disable-hover-tool-for-hidden-glyphs-via-interactive-legend

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!