From 061f2f9ed3d1dc9dbbc07d499a7c74a212d630b8 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 25 Sep 2026 14:24:27 +0200 Subject: [PATCH 1/2] use layout args (tight_layout= is discouraged) --- src/silx/gui/plot/backends/BackendMatplotlib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/silx/gui/plot/backends/BackendMatplotlib.py b/src/silx/gui/plot/backends/BackendMatplotlib.py index 7433eda591..4d033eea14 100755 --- a/src/silx/gui/plot/backends/BackendMatplotlib.py +++ b/src/silx/gui/plot/backends/BackendMatplotlib.py @@ -522,7 +522,7 @@ def __init__(self, plot, parent=None): self._axesDisplayed = True self.fig = Figure( - tight_layout=config._MPL_TIGHT_LAYOUT, + layout="tight" if config._MPL_TIGHT_LAYOUT else None, ) self.fig.set_facecolor("w") From 4d6272ed3bc0b171f8f5117ec9d289c7ff08cb38 Mon Sep 17 00:00:00 2001 From: Thomas VINCENT Date: Fri, 25 Sep 2026 14:25:42 +0200 Subject: [PATCH 2/2] use plot bounds instead of fig.get_window_extent to match effective plot area aspect ratio --- src/silx/gui/plot/backends/BackendMatplotlib.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/silx/gui/plot/backends/BackendMatplotlib.py b/src/silx/gui/plot/backends/BackendMatplotlib.py index 4d033eea14..26adcef7a0 100755 --- a/src/silx/gui/plot/backends/BackendMatplotlib.py +++ b/src/silx/gui/plot/backends/BackendMatplotlib.py @@ -1247,13 +1247,13 @@ def _setPlotBounds( if not self.isKeepDataAspectRatio(): newXRange, newYRange, newY2Range = xRange, yRange, y2Range else: - bbox = self.fig.get_window_extent() + plotWidth, plotHeight = self.getPlotBoundsInPixels()[2:] if keepDim is None: xDataRange, yDataRange, _ = self._plot.getDataRange() - keepDim = findDimToKeep(bbox.width, bbox.height, xDataRange, yDataRange) + keepDim = findDimToKeep(plotWidth, plotHeight, xDataRange, yDataRange) newXRange, newYRange, newY2Range = ensureAspectRatio( - bbox.width, - bbox.height, + plotWidth, + plotHeight, xRange, yRange, y2Range,