Skip to content

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

Closed

Description

@anntzer

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:

Activity

  1. jklymak commented on Jun 22, 2020

    @jklymak
    Member

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

  2. tacaswell commented on Jun 22, 2020

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

  3. anntzer commented on Jun 22, 2020

    @anntzer
    ContributorAuthor

    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)
  4. jklymak commented on Jun 22, 2020

    @jklymak
    Member

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

  5. anntzer commented on Jun 22, 2020

    @anntzer
    ContributorAuthor

    #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).

  6. jklymak commented on Jun 22, 2020

    @jklymak
    Member

    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?

  7. QuLogic commented on Jun 23, 2020

    @QuLogic
    Member

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

  8. anntzer commented on Jun 23, 2020

    @anntzer
    ContributorAuthor

    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

  9. changed the title [-]constrained_layout fails on suptitle+colorbars+fullscreen toggle[/-] [+]constrained_layout fails on suptitle+colorbars+some figure sizes[/+] on Jun 23, 2020
  10. jklymak commented on Jun 23, 2020

    @jklymak
    Member

    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.

  11. linked a pull request that will close this issueRewrite of constrained_layout.... #17494on Jun 25, 2020
  12. added this to the v3.4.0 milestone on Aug 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: geometry managerLayoutEngine, Constrained layout, Tight layout

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions