如何在Holoviews中设置活动工具 [英] How to set active tools in Holoviews

查看:62
本文介绍了如何在Holoviews中设置活动工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候,我的图是在pan工具处于活动状态时绘制的,有时它们在panwheel_zoom是处于活动状态时绘制的.我想强制wheel_zoom在渲染时处于活动状态.有办法吗?

Sometimes my plots get drawn with the pan tool active and sometimes they draw with pan and wheel_zoom active. I'd like to force wheel_zoom to be active upon rendering. Is there a way to do this?

推荐答案

自holoviews 1.11.0发布以来,原始答案已经过时. HoloViews现在有一个显式选项来设置活动工具,称为active_tools,它接受工具名称或实例的列表,例如要默认激活wheel_zoom工具,您可以执行以下操作:

Since holoviews 1.11.0 was released the original answer has been outdated. HoloViews now has an explicit option to set the active tool(s), called active_tools which accepts a list of tool names or instances, e.g. to activate the wheel_zoom tool by default you would do this:

 hv.Curve([1, 2, 3]).options(active_tools=['wheel_zoom'])

下面其余的答案已经过时了:

The rest of the answer below is outdated:

对于在HoloViews中没有直接公开的任何选项,您可以定义可以直接修改bokeh模型的挂钩.这是一个简单的示例,它定义了一个设置活动滚动工具的钩子(如

For any options that are not directly exposed in HoloViews you can define hooks which can directly modify the bokeh models. Here is a simple example that defines a hook to set the active scroll tool (as described in the bokeh docs):

def set_active_tool(plot, element):
    plot.state.toolbar.active_scroll = plot.state.tools[2]

hv.Curve([1, 2, 3]).options(finalize_hooks=[set_active_tool])

设置活动工具似乎是一个相当常见的操作,因此,提出一个问题以要求可以直接将活动工具声明为绘图选项,将不胜感激.

Setting the active tool seems like a fairly common action though, so filing an issue to request that the active tools can be declared directly as a plot option would be appreciated.

这篇关于如何在Holoviews中设置活动工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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