在bokeh python中删除工具栏项 [英] Remove toolbar item in bokeh python

查看:87
本文介绍了在bokeh python中删除工具栏项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要添加工具栏项,我们要做plot.add_tools(tool)与之相反的是,我想删除我所参考的特定工具?

To add a toolbar item, we do plot.add_tools(tool) What would be the opposite of this, where i want to remove a particular tool which I have reference to ?

推荐答案

图的Toolbar对象可用于删除工具-

The Toolbar object of the plot can be used to remove the 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, 2, 7], size=10)

show(p)

这将在工具栏中生成带有6个工具的图表.

This will generate a chart with 6 tools in toolbar.

假设需要删除WheelZoomTool.图的工具栏"对象将具有工具列表,并且可以从此处删除该工具-

Suppose, WheelZoomTool needs to be removed. The Toolbar object of plot will have a list of tools, and this tool can be deleted from there -

import bokeh
for tool in p.toolbar.tools:
    if isinstance(tool, bokeh.models.tools.WheelZoomTool):
        p.toolbar.tools.remove(tool)
show(p)

WheelZoomTool从输出中消失了

WheelZoomTool is gone from output

这篇关于在bokeh python中删除工具栏项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆