☰Read-only archive⌕
Looking for help with Bokeh?

This is a read-only archive. Ask questions and join the conversation on GitHub.

Visit Community Support on GitHub →
Archived discussions · Captured October 28, 2026

Unable to set active state when passing tools as a list of functions

Community Support
mbilyanov
mbilyanov

I have the following bit of code to define the tools for my plot.

tools = [
    PanTool(),
    BoxZoomTool(),
    WheelZoomTool(),
    ResetTool(),
    CrosshairTool(),
    SaveTool(),
    HoverTool(
        tooltips=tooltips_top,
        formatters={'@time': 'datetime'}
     )
 ]
 
 p1 = figure(plot_width=600,
             plot_height=400,
             tools=tools,
             x_axis_type='datetime',
             sizing_mode='stretch_width',
             tooltips=tooltips_top,
             y_axis_location="right")

I’m not able to define the initial active_drag state. I tried many things such as:
p1.toolbar.active_drag = 'xpan'

but I’m not sure how to get this working.

The following approach works, but then I cannot configure the tools:

tools='xpan, xwheel_zoom, xbox_zoom, reset, hover',
active_drag='xpan',
active_scroll='xwheel_zoom'

I don’t know how to mix those two approaches, where you provide the tools as a list of strings and as a list of functions.

Sorry, I had to edit my question so it is a bit more clear.

⌁   Link to post
mbilyanov
mbilyanov

Hi,

Sorry, I don’t understand. Basically, when I provide the tools as a list of tool names, such as below:

tools='xpan, xwheel_zoom, xbox_zoom, reset, hover',

I can do the following:

active_drag='xpan',
active_scroll='xwheel_zoom'

which works, but I also would like to customise some of the tools, like the hover tool for example, pass some custom settings to it.

So when I do this:

MY_TOOLS = [
    PanTool(),
    BoxZoomTool(),
    WheelZoomTool(),
    ResetTool(),
    CrosshairTool(),
    SaveTool(),
    HoverTool(
        tooltips=tooltips_top,
        formatters={'@time': 'datetime'}
     )
 ]

 tools=MY_TOOLS

I can no longer define the active_drag and the active_scroll states.

⌁   Link to post
mbilyanov
mbilyanov

Yes! Thank you very much.

One final thing though, how can I have the xpan mode in the above scenario?

active_drag=xpan_tool

Now I get the X and Y pan by using the pan_tool = PanTool()

Is there my_pan_tool = PanTool(axis='X') ?

⌁   Link to post

End of archived discussion · Replies are disabled