Maintaining data aspect when resizing the browser window

Hello,

I’m trying to maintain the scale of the data while allowing the plot window to stretch as the browser window is resized. The following code works as intended until the data is either panned or zoomed, in which case the aspect ratio of the data is lost. When the ResetTool button is pressed, it again works properly until the data is panned or zoomed.

How can I make this work?

Thanks!

from bokeh.plotting import figure
from bokeh.models.tools import BoxZoomTool, ResetTool, PanTool, WheelZoomTool
from bokeh.io import show

tools = [
        PanTool(),
        BoxZoomTool(match_aspect=True),
        WheelZoomTool(),
        ResetTool(),
        ]

f = figure(tools=tools,
            sizing_mode="stretch_both",
            match_aspect=True,
            active_drag=tools[0], 
            toolbar_location="above", # if set to "below", to scrollbars flicker rapidly in the browser
            )

poly = f.patch(x=[100, 200, 200, 100], y=[100, 100, 200, 200])

show(f)

FYI:
bokeh=3.3.4
python=3.9.18
OS=windows 10
browser=Chrome, Firefox

Aspect matching only functions when auto-ranging is active. If the range bounds are explicitly set for any reason, e.g. you because you manually set start or end or because an interactive tool set them, then Bokeh respects the explicit setting—whatever it is, aspect matched or not—and will not override it.