-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: adjust_bbox should not modify layout engine #24971
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
6e4153c
to
e93b150
Compare
e93b150
to
3c28528
Compare
@@ -532,6 +532,13 @@ def test_savefig_pixel_ratio(backend): | |||
assert ratio1 == ratio2 | |||
|
|||
|
|||
def test_savefig_preserve_layout_engine(tmp_path): |
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.
This worked before didn't it? It was when the rcParam was set that the problem was? Or was the layout still getting set to None, and then falling back to the rcParam?
Otherwise if this works, I'm all for it! I do wish all the context switching were simpler to debug, but...
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.
On main
this test throws an AttributeError
because the layout engine got set to None
. If we set the rcParam then we would get an assertion error on main
. I'm happy to test either or both.
Thanks for tracking this down @rcomer ! Great detective work.... |
…971-on-v3.7.x Backport PR #24971 on branch v3.7.x (FIX: adjust_bbox should not modify layout engine)
PR Summary
Fixes #24954 (I think!) I don't claim to fully understand everything that's going on here, but it seems to me that these lines are doing the same job as
matplotlib/lib/matplotlib/backend_bases.py
Lines 2356 to 2357 in 018c5ef
Since
restore_bbox
gets called within the above context manager, the final result is the layout engine continues to be what was set withfig.set_layout_engine(None)
.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