diff --git a/lib/matplotlib/backends/backend_wx.py b/lib/matplotlib/backends/backend_wx.py index d2fd3c5218ab..05e20a0d93f1 100644 --- a/lib/matplotlib/backends/backend_wx.py +++ b/lib/matplotlib/backends/backend_wx.py @@ -947,8 +947,21 @@ def _onSize(self, evt): """ DEBUG_MSG("_onSize()", 2, self) + sz = self.GetParent().GetSizer() + if sz: + si = sz.GetItem(self) + if sz and si and not si.Proportion and not si.Flag & wx.EXPAND: + # managed by a sizer, but with a fixed size + size = self.GetMinSize() + else: + # variable size + size = self.GetClientSize() + if getattr(self, "_width", None): + if size == (self._width, self._height): + # no change in size + return + self._width, self._height = size # Create a new, correctly sized bitmap - self._width, self._height = self.GetClientSize() self.bitmap = wxc.EmptyBitmap(self._width, self._height) self._isDrawn = False