只要设定
toggleable
False
. 选中此示例,其中悬停工具按钮处于隐藏状态:
from bokeh.models import HoverTool, ColumnDataSource, LassoSelectTool, PanTool
from bokeh.plotting import show, figure, curdoc
source = ColumnDataSource(dict(
x=[1, 2, 3, 4],
y=[5, 6, 7, 8]
))
p = figure(
width=400,
height=400,
tools='')
p.scatter(
x='x', y='y', source=source,
fill_alpha=1.0, line_alpha=1.0, line_color="grey",
size=6
)
pan = PanTool()
lasso = LassoSelectTool()
tooltips = '''
<b>X: </b> @{x} <br>
<b>Y: </b> @{y} <br>
'''
hover = HoverTool(
toggleable=False, # add this to all your hover tools
mode='mouse',
tooltips=tooltips,
)
tools = (
pan, lasso, hover
)
p.add_tools(*tools)
curdoc().add_root(p)
如果你只想使用一个按钮,那么你可以只使用一个悬停工具。模型
CustomJSHover
作为解决方法,您还可以更新
renderers