在不丢失其余工具的情况下将悬停添加到散景
Add hover to Bokeh without losing rest of tools
所以对于 Bokeh,我可以做这样的事情来创建悬停选项:
From bokeh.models import HoverTool #add hover functionality
Hover = HoverTool(tooltips=[(name1:@column1), (name2:@columns2)])
Plot = figure(tools=[hover])
Plot.circle(x,y,hover_color=’red’)
但是,通过这样做,我失去了调用 figure() 时获得的标准工具,例如 pan、box_zoom、wheel_zoom 等。我知道我可以通过以下方式将它们加回 1 1 inside the figure(tools=[]),但是有没有办法只在 figure() 的其余默认工具中添加悬停,在它被定义之后??
谢谢!
使用 add_tools() 方法,如文档中所述:
https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#specifying-tools
文档中的示例稍作修改:
from bokeh.plotting import figure, output_file, show
from bokeh.models import HoverTool
output_file("toolbar.html")
# create a new plot with the toolbar below
p = figure(plot_width=400, plot_height=400,
title=None, toolbar_location="below")
p.circle([1, 2, 3, 4, 5], [2, 5, 8, 2, 7], size=10)
p.add_tools(HoverTool())
show(p)
所以对于 Bokeh,我可以做这样的事情来创建悬停选项:
From bokeh.models import HoverTool #add hover functionality
Hover = HoverTool(tooltips=[(name1:@column1), (name2:@columns2)])
Plot = figure(tools=[hover])
Plot.circle(x,y,hover_color=’red’)
但是,通过这样做,我失去了调用 figure() 时获得的标准工具,例如 pan、box_zoom、wheel_zoom 等。我知道我可以通过以下方式将它们加回 1 1 inside the figure(tools=[]),但是有没有办法只在 figure() 的其余默认工具中添加悬停,在它被定义之后??
谢谢!
使用 add_tools() 方法,如文档中所述:
https://docs.bokeh.org/en/latest/docs/user_guide/tools.html#specifying-tools
文档中的示例稍作修改:
from bokeh.plotting import figure, output_file, show
from bokeh.models import HoverTool
output_file("toolbar.html")
# create a new plot with the toolbar below
p = figure(plot_width=400, plot_height=400,
title=None, toolbar_location="below")
p.circle([1, 2, 3, 4, 5], [2, 5, 8, 2, 7], size=10)
p.add_tools(HoverTool())
show(p)