How to set active tools in Holoviews

混江龙づ霸主 提交于 2019-12-09 03:24:26

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:

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!