bokeh: [BUG] Zooming inverts axis

Software versions

Python version : 3.10.13 | packaged by conda-forge | (main, Oct 26 2023, 18:09:17) [Clang 16.0.6 ] IPython version : 8.17.2 Tornado version : 6.3.3 Bokeh version : 3.3.0 BokehJS static path : /Users/droumis/opt/miniconda3/envs/timeseries/lib/python3.10/site-packages/bokeh/server/static node.js version : v20.4.0 npm version : 9.7.2 Operating system : macOS-13.5.2-arm64-arm-64bit

Browser name and version

No response

Jupyter notebook / Jupyter Lab version

Observed in both Jupyter Lab 4 and VS Code

Expected behavior

I don’t expect zoom to invert an axis.

Observed behavior

zooming occasionally inverts the x/y axes.

Example code

from bokeh.plotting import figure, show
from bokeh.io import output_notebook

output_notebook()

x = [1, 2, 3, 4, 5]
y = [6, 7, 2, 4, 5]

p = figure(title="simple line example", x_axis_label='x', y_axis_label='y')

p.line(x, y, legend_label="Temp.", line_width=2)

show(p)

Stack traceback or browser console output

No response

Screenshots

https://github.com/bokeh/bokeh/assets/6613202/3cacb80b-877e-42da-bf3c-2db008e0d659

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 15 (9 by maintainers)

Most upvoted comments

I’m going to go ahead and push a tiny PR with this fix. Unless there’s disagreement I’d propose merging ASAP and quickly backporting to 3.6.3 as well. I do think the WheelZoomTool logic (esp. the zoom function) needs to be refactored some as it’s grown somewhat unwieldy by this point, but that can wait.

here is another minimal reproducible example. Hopefully it can help. The larger the array, the easier it is to reproduce.

import numpy as np
from bokeh.plotting import column, figure, show


p = figure(
    width=800,
    height=500,
    tools="xwheel_zoom,reset",
    active_scroll="xwheel_zoom",
    output_backend="webgl",
)

j = np.array(list(range(1000000)))
p.scatter(j, j)

show(p)

In this plot the slope should always be positive. When wheel zooming in too quickly, it is easy to see the slope incorrectly change to negative.

https://github.com/user-attachments/assets/14925e70-8d87-4fbc-be04-d22fc5c034b6

Thanks @bryevdv for taking a look!

Any plans to fix this? This happens a lot for us, really quite a big deal. (we’re using Bokeh 3.6.0)