☰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

Adding two BoxZoomTools (with different settings) to the same toolbar

Community Supportbokeh
bevoorrading
bevoorrading

I need to have one BoxZoomTool that is restricted to zoom only in the width. But I also need one that can zoom in the other direction(s). (Ideally, I’d have one tool with some way of doing both actions.)

However, it doesn’t seem possible for me to add two BoxZoomTools to the same toolbar. If I do, only one appears and doesn’t seem to work.
Is this because of how the toolbar is made? Or is there a way to do this?

Thanks

⌁   Link to post
bevoorrading
bevoorrading

Ok, thanks for the example. I figured out what is going wrong. This doesn’t seem to work with merge_tools=True in gridplot (which is also the default value).

For example:

from bokeh.plotting import figure, show
from bokeh.models import BoxZoomTool
from bokeh.layouts import gridplot

plot = figure(width=400, height=400, tools='reset')
plot.circle([1, 2, 3], [1, 2, 3], size=20)

plot.add_tools(BoxZoomTool())
plot.add_tools(BoxZoomTool(dimensions='width'))
plot.add_tools(BoxZoomTool(dimensions='height'))

plot2 = figure(width=400, height=400, tools='reset')
plot2.circle([3, 2, 1], [1, 2, 3], size=20)

plot2.add_tools(BoxZoomTool())
plot2.add_tools(BoxZoomTool(dimensions='width'))
plot2.add_tools(BoxZoomTool(dimensions='height'))

show(gridplot([[plot], [plot2]],sizing_mode="stretch_both",merge_tools=True))

Note that if you set merge_tool=False, it works again.
Would this constitute a bug?

⌁   Link to post

End of archived discussion · Replies are disabled