From 1b82a9627dcd75be1add8ed796ad09266d8a4166 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 27 Mar 2020 02:30:56 -0400 Subject: [PATCH] tk: Resize the canvas, not the figure. Resizing the figure directly does not account for the toolbar, so figures are actually a little shorter than they should be. The recent change to `Text.get_window_extent` some how causes this to actually get reflected in the Matplotlib figure size, which cycles back to Tk and shrinks the window. However, this can be triggered by other calls to `Figure.set_size_inches` as noted in the fixed issues. Fixes #10083. Fixes #10566. Fixes #16926. --- lib/matplotlib/backends/_backend_tk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/backends/_backend_tk.py b/lib/matplotlib/backends/_backend_tk.py index a982385a87a2..9549d57c24b7 100644 --- a/lib/matplotlib/backends/_backend_tk.py +++ b/lib/matplotlib/backends/_backend_tk.py @@ -446,7 +446,7 @@ def _get_toolmanager(self): return toolmanager def resize(self, width, height): - self.canvas._tkcanvas.master.geometry("%dx%d" % (width, height)) + self.canvas._tkcanvas.configure(width=width, height=height) if self.toolbar is not None: self.toolbar.configure(width=width)