I already tried match_aspect
and it does not work. But I guess, I am doing something wrong. Consider the following code:
import numpy as np
import panel as pn; pn.extension()
import bokeh as bk
from bokeh import plotting
image = np.random.random((256, 256))
figure_args = {}
figure_args['tools'] = "pan,wheel_zoom,box_zoom,save,reset"
figure_args['active_scroll'] = "wheel_zoom"
figure_args['match_aspect'] = True
figure_args['sizing_mode'] = 'stretch_both'
fig = plotting.figure(**figure_args)
fig.toolbar.logo = None
color_mapper = bk.models.LinearColorMapper(palette=bk.palettes.Viridis256, low=0, high=1)
fig.image(image=[image], x=[0], y=[0], dw=[256], dh=[256], color_mapper=color_mapper)
color_bar = bk.models.ColorBar(color_mapper=color_mapper, location=(0, 0))
fig.x_range.range_padding = 0
fig.y_range.range_padding = 0
pn.pane.Bokeh(fig)
Zooming with the box tool, let you zoom without keeping the aspect ratio and so the pixel end up being deformed.