问题
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?
回答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.
来源:https://stackoverflow.com/questions/50415434/how-to-set-active-tools-in-holoviews