Skip to content Skip to sidebar Skip to footer

How To Set Active Tools In Holoviews

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 w

Solution 1:

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.

Post a Comment for "How To Set Active Tools In Holoviews"