Skip to content

Commit 53a5bc6

Browse files
authored
Merge pull request matplotlib#29989 from sandyowlet/bugfix/issue-28330
fix: Fix unstable tkagg small plot size.
2 parents 8e7ad16 + 185b4fa commit 53a5bc6

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/matplotlib/backends/_backend_tk.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,14 @@ def __init__(self, canvas, window=None, *, pack_toolbar=True):
667667
window = canvas.get_tk_widget().master
668668
tk.Frame.__init__(self, master=window, borderwidth=2,
669669
width=int(canvas.figure.bbox.width), height=50)
670+
# Avoid message_label expanding the toolbar size, and in turn expanding the
671+
# canvas size.
672+
# Without pack_propagate(False), when the user defines a small figure size
673+
# (e.g. 2x2):
674+
# 1. Figure size that is bigger than the user's expectation.
675+
# 2. When message_label is refreshed by mouse enter/leave, the canvas
676+
# size will also be changed.
677+
self.pack_propagate(False)
670678

671679
self._buttons = {}
672680
for text, tooltip_text, image_file, callback in self.toolitems:

0 commit comments

Comments
 (0)