Skip to content

Fix bug when resizing qt4 figure window. #756

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

Merged
merged 1 commit into from
Jun 1, 2012

Conversation

tonysyu
Copy link
Contributor

@tonysyu tonysyu commented Mar 11, 2012

Resizing window didn't account for toolbar and status bar heights.

This PR duplicates #748, but is based off of v1.1.x instead of master.

Resizing window didn't account for toolbar and status bar heights.
@jdh2358
Copy link
Collaborator

jdh2358 commented Mar 17, 2012

Sorry to be dense but what do I need to do to see the before and after behavior. I tries launching the simple_plot.py example before and after w/ the qt4agg backend and resizing the window, but didn't notice any difference.

@tonysyu
Copy link
Contributor Author

tonysyu commented Mar 17, 2012

Sorry, I wasn't clear in the pull request: this is for resizing in code. I sent the following to the mailing list, but forgot to add it to the PR.

import matplotlib as mpl
mpl.use('qt4agg')
import matplotlib.pyplot as plt

fig = plt.figure()
fig.set_size_inches(2, 2, forward=True)

plt.figure(figsize=(2, 2))

plt.show()

In theory, the two figures should be the same size, but since the code path for set_size_inches doesn't account for the bar heights, the figures are different sizes.

@tonysyu
Copy link
Contributor Author

tonysyu commented Mar 17, 2012

BTW, in the email, I mentioned that I couldn't test whether this change affected figure.set_figwidth or figure.set_figheight because I couldn't get the figure to update with these settings (i.e. the set the figure's bbox_inches attribute but this doesn't get called when drawn). The forward parameter here accesses a block of code that doesn't seem to be available elsewhere, which is a bit confusing (I would expect set_figwidth and set_figheight to have access to the same code).

@efiring
Copy link
Member

efiring commented Mar 17, 2012

This anomaly is not confined to the qt4agg backend; I see it in the gtkagg backend also. TkAgg gives wildly different sizes. WxAgg gives two windows the same size, but without the unit aspect ratio that the canvas area should have.

It's a real mess.

@tonysyu
Copy link
Contributor Author

tonysyu commented Mar 18, 2012

Yeah, I noticed the TkAgg issue as well (I don't have GTK or Wx installed). I tried to dig into the TkAgg backend, but for some reason, I came to the conclusion that I would not be able to figure out a fix without considerable effort.

And macosx has issues too: resizing causes a dark gray region to shrink to the specified size, but the window itself remains unchanged.

@mdboom
Copy link
Member

mdboom commented Jun 1, 2012

Ah, this is a mess. It would be great to get to the bottom of this. And while, of course, it's ideal to fix this in all backends, since this is really a bugfix and not a new feature, I think it's find to merge this and file a new issue that resizing doesn't work correctly in the gtk, wx, tk backends. Better that than to hold up this PR waiting for all the other backends to be fixed.

efiring added a commit that referenced this pull request Jun 1, 2012
Fix bug when resizing qt4 figure window.
@efiring efiring merged commit 04e87dd into matplotlib:v1.1.x Jun 1, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants