Skip to content

Commit 1b82a96

Browse files
committed
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 matplotlib#10083. Fixes matplotlib#10566. Fixes matplotlib#16926.
1 parent 5e74fb4 commit 1b82a96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/backends/_backend_tk.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,7 @@ def _get_toolmanager(self):
446446
return toolmanager
447447

448448
def resize(self, width, height):
449-
self.canvas._tkcanvas.master.geometry("%dx%d" % (width, height))
449+
self.canvas._tkcanvas.configure(width=width, height=height)
450450

451451
if self.toolbar is not None:
452452
self.toolbar.configure(width=width)

0 commit comments

Comments
 (0)