Skip to content

The default backend (Qt4Agg) seems to change the figure size #7472

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Patrick5 opened this issue Nov 16, 2016 · 11 comments
Closed

The default backend (Qt4Agg) seems to change the figure size #7472

Patrick5 opened this issue Nov 16, 2016 · 11 comments
Labels
GUI: Qt OS: Microsoft status: inactive Marked by the “Stale” Github Action

Comments

@Patrick5
Copy link

The default backend (Qt4Agg) seems to be changing my figure size. The problem does not occur in AGG, TKAGG, or WEBAGG backends. I have not tested others.

Matplotlib version: 1.5.3 installed via anaconda
Python version: 3.5.2
Platform: Windows 8.1

The following is the minimal code I came up with that will reproduce the problem:

import matplotlib.pyplot as plt
fig = plt.figure()
print('size before:', fig.get_size_inches())
fig.canvas.flush_events()
fig.canvas.flush_events()
print('size after:', fig.get_size_inches())

This produces console output:
size before: [ 8. 6.]
size after: [ 8. 5.95]

In more general use this typically arises after a couple of frames have been displayed, and specifically causes a problem when making a movie from those displayed images: the output rolls by 5 pixels from frame to frame. Playing back the resulting mp4 looks like an old analog TV with the vertical sync out of whack.

BTW, one workaround is to call fig.set_size_inches(8,6) after the second flush above but before any frames are generated or grabbed, as the size does not seem to get changed again.

@tacaswell tacaswell added this to the 2.0.1 (next bug fix release) milestone Nov 17, 2016
@tacaswell
Copy link
Member

related to #7353

@QuLogic
Copy link
Member

QuLogic commented Dec 11, 2016

I can't seem to reproduce this with Qt4; are you sure you aren't using Qt5?

QuLogic added a commit to QuLogic/matplotlib that referenced this issue Dec 11, 2016
Even though the minimum height is set, that doesn't seem to carry over
to the size hint that gets used later to determine the size of the
entire window, causing the window to be a bit too short and changing the
size of the canvas.

Fixes matplotlib#7353. Probably also fixes matplotlib#7472.
@tacaswell
Copy link
Member

@QuLogic I thought I was using qt4 in #7353 , but I could be wrong (as I work in conda envs and may have accidentally jumped to qt5 and I know @anntzer is using qt5).

@Patrick5 The 1.5.3 builds from continuum pin to qt5 (see ContinuumIO/anaconda-issues#1068) Can you check the output of matplotlib.get_backend()?

@anntzer
Copy link
Contributor

anntzer commented Dec 11, 2016

FWIW I cannot reproduce this with mpl1.5.3 or 2.0rc1 / qt4agg or qt5agg on Arch Linux.

@QuLogic
Copy link
Member

QuLogic commented Dec 11, 2016

Weird, I thought I could reproduce this yesterday, but I can't seem to find those results and can't reproduce now. Anyway, if it's actually Qt5, then I'm pretty sure this is the same as #7353.

@Patrick5
Copy link
Author

Patrick5 commented Dec 12, 2016 via email

@tacaswell
Copy link
Member

@Patrick5 Can you try with #7610 ? I am not sure which of of our devs overlap between qt and windows users.

@tacaswell tacaswell modified the milestones: 2.0 (style change major release), 2.0.1 (next bug fix release) Dec 17, 2016
@tacaswell
Copy link
Member

Manually re-opening as this may be OS specific.

@tacaswell tacaswell reopened this Dec 17, 2016
@QuLogic QuLogic modified the milestones: 2.0.1 (next bug fix release), 2.0.2 (next bug fix release) May 3, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
@QuLogic
Copy link
Member

QuLogic commented May 15, 2020

Based on #17391, this seems to only be a problem with Qt5Agg on macOS now.

QuLogic added a commit to QuLogic/matplotlib that referenced this issue May 16, 2020
It's currently failing because of incorrect resizing when the window is
opened.

matplotlib#7472
@github-actions
Copy link

github-actions bot commented Apr 2, 2023

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 2, 2023
@tacaswell
Copy link
Member

I could not reproduce this on OSX with the qtAgg backend. I am going to close this is fixed unless someone else can reproduce it.

@tacaswell tacaswell removed this from the future releases milestone Apr 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI: Qt OS: Microsoft status: inactive Marked by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

4 participants