Skip to content

constrained_layout fails on suptitle+colorbars+some figure sizes #17712

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
anntzer opened this issue Jun 22, 2020 · 9 comments · Fixed by #17494
Closed

constrained_layout fails on suptitle+colorbars+some figure sizes #17712

anntzer opened this issue Jun 22, 2020 · 9 comments · Fixed by #17494
Labels
topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Milestone

Comments

@anntzer
Copy link
Contributor

anntzer commented Jun 22, 2020

Bug report

Bug summary

After

from pylab import *

fig = plt.figure(figsize=(8, 5), constrained_layout=True)
fig.suptitle("foo")
axs = fig.subplots(1, 2, sharex=True, sharey=True)
im = axs[0].imshow([[1, 2], [3, 4]])
fig.colorbar(im, ax=axs[0], orientation="horizontal")
im = axs[1].imshow([[1, 2], [3, 4]])
fig.colorbar(im, ax=axs[1], orientation="horizontal")
plt.show()

and toggling manually to fullscreen, one gets
test
i.e. the suptitle is placed too low.

Note that this doesn't happen if the call to suptitle() comes last instead of first.

Matplotlib version

  • Operating system: linux
  • Matplotlib version: master
  • Matplotlib backend (print(matplotlib.get_backend())): gui+agg/mplcairo
  • Python version: 38
  • Jupyter version (if applicable):
  • Other libraries:
@anntzer anntzer added the topic: geometry manager LayoutEngine, Constrained layout, Tight layout label Jun 22, 2020
@jklymak
Copy link
Member

jklymak commented Jun 22, 2020

I don't get this with either macOSx or qt5Agg on my mac. I don't understand what could cause this, or why the order would make a difference (the subtitle gets placed the same regardless).

@tacaswell
Copy link
Member

@anntzer are you using a tiling window manager? I have seen issues with tiling managers some getting out of sync with figure sizes.

That said, with qtile I can not reproduce this.

@anntzer
Copy link
Contributor Author

anntzer commented Jun 22, 2020

No, I am using a boring defaultish KDE.
I confirm I observe this with the following combos:

  • master + {qt5,gtk3,wx,tk}agg (fedora+KDE)
  • 3.2.0 + qt5agg (idem)
  • master + qt5agg (windows)

@jklymak
Copy link
Member

jklymak commented Jun 22, 2020

I don't get this with #17494 either. It changes how colorbars are handled, so maybe worth checking out

@anntzer
Copy link
Contributor Author

anntzer commented Jun 22, 2020

#17494 appears to fix the problem; I guess that's a good argument in favor of it :)
Also, looks like (on master) the behavior is slightly different depending on whether full-screen is toggled by pressing F or by double clicking the title bar (but both are wrong).

@jklymak
Copy link
Member

jklymak commented Jun 22, 2020

Curious. OTOH I can't get this at all, using F, or maximizing w/ the green dot, so I can't really help. I would guess its something wrong w/ how your window manager reports back sizes when at full screen, but not sure?

@QuLogic
Copy link
Member

QuLogic commented Jun 23, 2020

I can reproduce this, and #17494 does fix both maximizing and fullscreen.

@anntzer
Copy link
Contributor Author

anntzer commented Jun 23, 2020

Actually, this is independent of fullscreening and just depends on the actual aspect ratio of the window (and thus indirectly on the aspect ratio of a full-screen window, with or without the titlebar as that is removed by "F"): I can repro the same issue with just

from pylab import *

fig = plt.figure(figsize=(8, 4), constrained_layout=True)  # <- note the change in size
fig.suptitle("foo")
axs = fig.subplots(1, 2, sharex=True, sharey=True)
im = axs[0].imshow([[1, 2], [3, 4]])
fig.colorbar(im, ax=axs[0], orientation="horizontal")
im = axs[1].imshow([[1, 2], [3, 4]])
fig.colorbar(im, ax=axs[1], orientation="horizontal")
plt.show()

and no window size manipulation. (The fact that the result depends on whether suptitle() is called first or last remains, though.)

With #17494 I now get a different issue wrt colorbars:
test

@anntzer anntzer changed the title constrained_layout fails on suptitle+colorbars+fullscreen toggle constrained_layout fails on suptitle+colorbars+some figure sizes Jun 23, 2020
@jklymak
Copy link
Member

jklymak commented Jun 23, 2020

OK, fair enough - I can reproduce that. I guess we just have very different aspect ratio screens.

Not sure we should fix this since there is an easy work around, and I'd prefer to get #17494 to work.

WRT the overlapping colorbars, I can work on that in the context of #17494.... Colorbars are the hardest thing about the layout managers.

@jklymak jklymak linked a pull request Jun 25, 2020 that will close this issue
6 tasks
@QuLogic QuLogic added this to the v3.4.0 milestone Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: geometry manager LayoutEngine, Constrained layout, Tight layout
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants