问题描述
要添加工具栏项,我们要做plot.add_tools(tool) 与之相反的是,我想删除我参考的特定工具?
解决方法
图的工具栏对象可用于删除工具-
from bokeh.plotting import figure,output_file,show,output_notebook
output_notebook()
# 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,7],size=10)
show(p)
这将在工具栏中生成带有6个工具的图表。
假设需要删除WheelZoomTool。图的“工具栏”对象将具有工具列表,可以从此处删除该工具-
import bokeh
for tool in p.toolbar.tools:
if isinstance(tool,bokeh.models.tools.WheelZoomTool):
p.toolbar.tools.remove(tool)
show(p)
WheelZoomTool从输出中消失了