-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Prevents axes limits from being resized by axes.fill_between #25712
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.
This could probably use a test of this behavior, something like the code from #25682 I don't think it needs to be an image comparison test, just an assertion that the limits are the same before/after the |
lib/matplotlib/axes/_axes.py
Outdated
if "transform" not in kwargs: | ||
self.update_datalim(pts, updatex=True, updatey=True) |
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 should probably check the transform branches, similar to how lines do:
matplotlib/lib/matplotlib/axes/_base.py
Line 2354 in 690884f
updatex, updatey = line_trf.contains_branch_seperately(self.transData) |
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.
That may be a bit more complete, yeah... for reference I based the original suggestion on axline:
matplotlib/lib/matplotlib/axes/_axes.py
Lines 910 to 913 in b86ebba
if "transform" in kwargs: | |
# if a transform is passed (i.e. line points not in data space), | |
# data limits should not be adjusted. | |
datalim = [] |
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.
@QuLogic I'm not yet very well-versed with transforms - wondering if you could provide some guidance as to how this would work?
I will continue to look into this as well.
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.
See #25324 for a similar application of the transform branches for update_datalim
on vlines
/hlines
. (Though I don't know for sure that you also need to handle rectilinear
specifically as is done in that PR; just the transform bit might be enough.)
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.
@ksunden I did a few basic image tests after initially making the changes: Additionally, I also tested with an assertion (per your recommendation) which verified that the axes limits remain the same before and after the
|
@olinjohnson could you make this a unit test in lib/matplotlib/tests/test_axes.py? https://matplotlib.org/stable/devel/testing.html#writing-a-simple-test This will help us to ensure that the expected behavior is retained through future changes. |
Yes! I added the unit test - sorry, should have done this before. |
Co-authored-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Thank you for your contribution, hope to hear from you again! |
PR Summary
Closes #25682 by preventing
Axes.fill_between()
from automatically adjusting the axes limits when using axes coordinates. When axes coordinates are not in use and thus no transformation is passed toAxes.fill_between()
, then adjusting the axes limits is necessary, but previously, in some cases, a transformation might have been in use and using axes coordinates could have caused the axes limits to be resized improperly.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