Fix constrainedlayout figartists#31425
Conversation
|
Thank you for opening your first PR into Matplotlib! If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. 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. |
| # === NEW: handle figure-level texts === | ||
| inv_trans_fig = fig.transFigure.inverted().transform_bbox | ||
|
|
||
| for text in fig.texts: |
There was a problem hiding this comment.
Please test locally on a minimal script that shows the before and after before pushing to GitHub. There is no way this worked locally with the typo here and you can see you are failing all the tests. I'll move this to draft
There was a problem hiding this comment.
Thanks for pointing that out, I missed testing locally and introduced a typo. I'm trying to fix the issue and verify the behavior with a minimal example. I'll keep iterating if anything else needs adjustment.
There was a problem hiding this comment.
Can you share the minimal example and before and after in the description of the PR? Also you appear to not have pushed any changes to the Github yet
Constrained layout currently does not account for figure-level artists such as fig.text() and fig.legend(), which can lead to overlaps or clipping of drawings or graphs.
This patch includes these artists in margin calculations using their tight bounding boxes, respecting visibility and get_in_layout().
A test is added to verify that figure-level text does not overlap axes.