【发布时间】:2020-08-21 15:46:21
【问题描述】:
要添加工具栏项,我们执行 plot.add_tools(tool) 与此相反的是什么,我想删除我引用的特定工具?
【问题讨论】:
-
为什么要删除工具而不是在图形创建时不包含它?
要添加工具栏项,我们执行 plot.add_tools(tool) 与此相反的是什么,我想删除我引用的特定工具?
【问题讨论】:
绘图的Toolbar对象可以用来移除工具-
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, 2, 7], size=10)
show(p)
这将在工具栏中生成一个包含 6 个工具的图表。
假设,WheelZoomTool 需要被移除。 plot的Toolbar对象会有一个工具列表,这个工具可以从那里删除-
import bokeh
for tool in p.toolbar.tools:
if isinstance(tool, bokeh.models.tools.WheelZoomTool):
p.toolbar.tools.remove(tool)
show(p)
WheelZoomTool 已从输出中消失
【讨论】: