如何在具有bokeh后端的全息视图中控制(活动)工具 [英] How to control (active) tools in holoviews with bokeh backend
问题描述
如何通过bokeh
后端控制在holoviews
图中使用/激活哪些工具?我已经看过这个SO答案,但是只有添加一个新的活动工具;不会阻止其他任何工具(例如平移)处于活动状态.
How do I control which tools are used / active in a holoviews
plot with the bokeh
backend? I've seen this SO answer, but that only adds a new active tool; it doesn't keep any other tools (e.g. pan) from being active.
对于一个特定的示例,假设我只想要悬停工具.我会尝试这样做:
For a specific example, suppose I only want the hover tool. I would try doing this:
import holoviews as hv
hv.extension("bokeh")
hv.Curve([1, 2, 3]).opts(tools=["hover"])
,但最后我得到了一个情节,该情节除了默认工具外还悬停了 .如何指定要使用的所有工具列表,以便不使用不在该列表中的工具?
but then I end up with a plot that has hover in addition to the default tools. How do I specify the list of all tools that I want to use, so that no tools are used that aren't in that list?
类似地,如何指定所有活动工具的列表?例如
Similarly, how do I specify the list of all active tools? E.g.
import holoviews as hv
hv.extension("bokeh")
hv.Curve([1, 2, 3]).opts(tools=["hover"], active_tools=[])
让我平移和悬停都活跃起来;我希望悬停是唯一的工具,但没有要激活的工具.
gives me both pan and hover being active; I want hover to be the only tool but no tool to be active.
推荐答案
对于第一个问题,请使用default_tools
选项:
For your first question, use default_tools
option:
hv.Curve([1, 2, 3]).opts(tools=["hover"], default_tools=[])
提出第二个问题,holoviews中没有方法可以执行此操作,但是您可以将其直接设置为Figure
对象:
fot the second question, there is not method in holoviews to do this, but you can set it to the Figure
object directly:
def set_tools(plot, element):
plot.state.toolbar.active_drag = None
hv.Curve([1, 2, 3]).opts(finalize_hooks=[set_tools])
这篇关于如何在具有bokeh后端的全息视图中控制(活动)工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!