-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Added logic to apply wspace and hspace in subfigures without constrained layout #25646
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a while, please feel free to ping @matplotlib/developers
or anyone who has commented on the PR. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
Thanks @dswelch. Have you checked what would happen if you had more than two rows or columns? From a quick look at the code, I think the outer rows/columns might end up wider than the middle ones. I’m also wondering if there’s a reason we can’t just use the subplotspec’s get_position method. |
Hi @rcomer, thank you for the feedback! You're correct that it does not work in the case of more than two rows or columns. Could you elaborate where I would use the get_position method? When experimenting with it by just returning the results of get_position, I got these results, with the constrained layout on the left and non constrained layout on the right: This is the same example that I used from the original issue, with wspace and hspace set to 0.2. I don't believe I fully understand what this function does so any guidance would be appreciated. |
Thanks for checking. As far as I can tell, the |
I just looked again at this and I realised that matplotlib/lib/matplotlib/gridspec.py Line 429 in 4bdae2e
So perhaps using matplotlib/lib/matplotlib/figure.py Lines 1568 to 1571 in 4bdae2e
@dswelch are you still interested in working on this and if so do you want to try that? I can't guarantee it will work! |
@rcomer I'm sorry for the late response, I would like to open up this issue to others if possible. If there is anything I should do to make that easier please let me know. |
Thanks for letting us know @dswelch. I’ll add the “orphan” label, then someone might adopt it. |
After some more discussion at #25511 I opened #25960 with a slightly different approach. So I will close this one in favour of that. Thank you for your work on this @dswelch. This one turned out to be somewhat thorny problem. I hope that that has not put you off and that we hear from you again some time. |
PR Summary
This is a PR for #25511
The wspace and hspace parameters in subfigures() did not have any affect when a constrained layout was not used.
The function _redo_transform_rel_fig in figure.py seemed to disregard the wspace and hspace parameters, so I added logic that would apply the correct spacing, based off of what I saw when using a constrained layout.
PR Checklist
Documentation and Tests
pytest
passes)Release Notes
.. versionadded::
directive in the docstring and documented indoc/users/next_whats_new/
.. versionchanged::
directive in the docstring and documented indoc/api/next_api_changes/
next_whats_new/README.rst
ornext_api_changes/README.rst