-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Redrawing canvas causes subplot positions to change when aspect='equal' used with rcParams['figure.autolayout'] = True #7648
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
Comments
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! |
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. |
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! |
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. |
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! |
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, 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:
|
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 issueThe 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
The text was updated successfully, but these errors were encountered: