You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Wrong figure height after set_size_inches within event handler #10083
When calling set_size_inches within an event handler, the new figure width is as requested, but the new height is not. This occurs with the TkAgg backend, but not the Qt5Agg backend (which suggests that this issue may not be related to #7302, since that issue is also reported to occur with Qt5Agg).
Code for reproduction
importmatplotlib.pyplotaspltfig=plt.figure(figsize=(8, 6))
defpress(event):
print('Before resize, size is ', fig.get_size_inches())
sz=1.1*fig.get_size_inches()
print('Size will be set to ', sz)
fig.set_size_inches(sz, forward=True)
fig.canvas.draw()
print('After resize, size is ', fig.get_size_inches())
fig.canvas.mpl_connect('key_press_event', press)
fig.show()
input()
Pressing any key while the cursor is within the figure will attempt to resize the figure. The requested and actual sizes are printed to the console. If
importmatplotlibmatplotlib.use('Qt5Agg')
is added at the start of this example, resizing behaves as expected.
This is likely the same issue, on changing the size of the figure we change the size of the window to fit the figure + the toolbar and on window resize adjust the figure to the space it actually has. I suspect that the issue is we are incorrectly accounting for the toolbar size (which fits with it being backend dependent as the exact details of that logic is GUI framework dependent.
Activity
tacaswell commentedon Dec 24, 2017
This is likely the same issue, on changing the size of the figure we change the size of the window to fit the figure + the toolbar and on window resize adjust the figure to the space it actually has. I suspect that the issue is we are incorrectly accounting for the toolbar size (which fits with it being backend dependent as the exact details of that logic is GUI framework dependent.
tk: Resize the canvas, not the figure.
gtk: Correctly resize canvas to intended size.
gtk: Correctly resize canvas to intended size.
gtk: Correctly resize canvas to intended size.
tk: Resize the canvas, not the figure.