Wheel_zoom problems?

When I try to use the wheel_zoom tool, I get some strange behavior. If I scroll just near an axis, it only changes that axis. Perhaps this is intended behavior? Is there a way to remove this behavior?

(minimal?) working example:

import pandas as pd
from bokeh.io import show
from bokeh.plotting import figure
from bokeh.models import HoverTool, ColumnDataSource, WheelZoomTool

df['x'] = pd.eval(df['x']) #convert to list
df['y'] = pd.eval(df['y']) #convert to list

hover = HoverTool(names=["1"])
TOOLTIPS='<font size="3"><b>@Feature</b> — @Type</font> <br> @Description'
p = figure(plot_height=plotDimen,plot_width=plotDimen, title="", toolbar_location=None, match_aspect=True,sizing_mode='scale_width',
               tools=[hover,'pan',"wheel_zoom"],active_scroll="wheel_zoom", tooltips=TOOLTIPS, x_range=(-plotSize, plotSize), y_range=(-plotSize, plotSize))
p.circle(x=0, y=0, radius=.205, line_color="#000000", fill_color=None, line_width=2)

source = ColumnDataSource(df)
p.patches('x', 'y', fill_color='fill_color', line_color='line_color', name="1", line_width=2, source=source)

Furthermore, this touches on an other “bug” I have encountered – as you can see the circle is /not/ scaled in one dimension along with the patches. This also happens when I view my Bokeh plot in Full Screen zoom view via Streamlit.

In regard to that last point, this issue also rears its head if you set the toolbar_location to any position besides None:

Ideally, the solution here is not to make the circle scale with the patches, but to make the patches not scale at all.

@mmcguffi That is indeed intended behavior, to allow for easily zooming in a single dimension. If you don’t want the axis-zooming behavior, you can set the zoom tool’s zoom_on_axis property to False.

Regarding the other question, I can dig up all the GH issues if you like, but TLDR; if you are plotting circles that have a radius in data-space units, you should probably always set match_aspect to True on the figure. That is the only way to ensure that the data-space aspect ratio, and the canvas pixel aspect ratio match up, and that is a necessary condition to avoid the situation above.

Thanks @Bryan!

In this example I do have match_aspect set to True on the plot however. Do you mean I need to set this for the individual circle?

@mmcguffi match_aspect is only a property of plots. Have you set explicit range values? match_aspect only works with default data ranges. If you set explicit range start/end values Bokeh assumes you know what you want and will not override what you specify (even if that means the aspect ratios won’t match).

1 Like

Ah, removing the explicit range values indeed did solve it. Thank you for the quick help with both issues @Bryan