FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Redrawing canvas causes subplot positions to change when aspect='equal' used with rcParams['figure.autolayout'] = True · Issue #7648 · matplotlib/matplotlib · GitHub

Repository navigation

Redrawing canvas causes subplot positions to change when aspect='equal' used with rcParams['figure.autolayout'] = True #7648

Closed as not planned

Description

As the title states, subplots with equal aspect ratio drift around within the figure when the canvas is redrawn with figure.autolayout set. The following code demonstrates the issue

import matplotlib.pyplot as plt
plt.rcParams['figure.autolayout'] = True

fig = plt.figure()
ax1 = fig.add_subplot(121, aspect='equal')
ax2 = fig.add_subplot(122, aspect='equal')
fig.canvas.mpl_connect('button_press_event', lambda event: event.canvas.draw())
fig.canvas.set_window_title('Click to redraw canvas')
plt.show()

The issue doesn't appear to occur with the default figure size, but if you resize the window horizontally the subplots drift around with each redraw until eventually settling on a position.

Platform: Windows 7
matplotlib: 1.5.3
python: 2.7.12

Activity

  1. modified the milestones: , on Dec 20, 2016
  2. tacaswell commented on Dec 20, 2016

    Member

    Interesting. There is obviously some coupled constraints here as the tight_layout code is trying to resize the axes to fill as much of the figure as possible and the equal aspect is trying to resize them so that the ratio between x/y is fixed in both data and screen space. We apply these constraints in sequence and they have now knowledge of each other.

    Calling draw is apparently running a steps of an iterative optimization!

  3. efiring commented on Dec 20, 2016

    Member

    Yes, aspect-ratio handling and tight_layout are essentially hacks developed independently to solve two different problems in the absence of any integrated layout system, and in the context of the existing paradigm with most positioning being done in normalized coordinates.

  4. modified the milestones: , on Oct 3, 2017
  5. github-actions commented on Apr 4, 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!

  6. jklymak commented on Apr 4, 2023

    Member

    For simple systems layout='compressed' helps a lot with this issue. For more complex systems you probably need to do the layout by hand. I'd vote to close this.

  7. github-actions commented on Apr 5, 2024

    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!

  8. tacaswell commented on Apr 5, 2024

    Member

    I'm going to close this as no-action. This is an unintended, but mostly harmless, interaction between two systems that adjust the layout late in the draw cycle. For back-compatibility reasons we really can not make siginifacnt changes to either and as Jody notes, layout='constrained' works correctly in this case:

    import matplotlib.pyplot as plt
    
    
    fig = plt.figure(layout='constrained')
    ax1 = fig.add_subplot(121, aspect='equal')
    ax2 = fig.add_subplot(122, aspect='equal')
    fig.canvas.mpl_connect('button_press_event', lambda event: event.canvas.draw())
    # fig.canvas.set_window_title('Click to redraw canvas')
    plt.show()

    In summary:

    • the bug is mostly harmless
    • fixing it could be very disruptive
    • we have a new layout system that works better
  9. removed this from the future releases milestone on Apr 5, 2024
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

    status: inactiveMarked by the “Stale” Github Action

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL