问题
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