Fix bug when resizing qt4 figure window. #756

Merged
merged 1 commit into from Jun 1, 2012

Projects

None yet

4 participants

@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.

@tonysyu tonysyu Fix bug when resizing qt4 figure window.
Resizing window didn't account for toolbar and status bar heights.
65828b5
@jdh2358
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
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
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
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
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
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 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