【问题标题】:Getting rid of hover icon in bokeh toolbar摆脱散景工具栏中的悬停图标
【发布时间】:2020-08-21 16:46:13
【问题描述】:

我想摆脱散景工具栏中出现的悬停图标以进行绘图并尝试下面的代码。

current_toolbars = plot.toolbar.__getattribute__('tools')
toolbars_to_retain = []
for toolbar_item in current_toolbars :
    if isinstance(toolbar_item, HoverTool) and some_other_condition_for_hover_tool :
       pass
    else :
       toolbars_to_retain.append(toolbar_item)

plot.toolbar.__setattribute__('tools', toolbars_to_retain)

但问题是,在这样做之后,绘图的整个工具栏都会崩溃

【问题讨论】:

标签: python bokeh toolbar


【解决方案1】:

您必须为此提供自定义 CSS。请注意,这种隐藏图标的方式很脆弱 - 它可能会因任何 Bokeh 更新而中断,因为它依赖于实现中未记录的部分。

from bokeh.core.templates import FILE
from bokeh.io import save
from bokeh.plotting import figure

p = figure(tools='hover')
p.circle(0, 0, size=100)

template = FILE.environment.from_string("""\
{% extends "file.html" %}
{% block postamble %}
<style>
.bk-toolbar-button.bk-tool-icon-hover {
    display: none;
}
</style>
{% endblock %}
""")

# Cannot use `show` because it doesn't accept a template.
save(p, template=template)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-11-22
    • 1970-01-01
    • 1970-01-01
    • 2015-02-17
    • 1970-01-01
    相关资源
    最近更新 更多