-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix axline
for slopes < 1E-8
#28431
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
Fix axline
for slopes < 1E-8
#28431
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 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.
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.
Hi @Andresporcruz, thanks for your contribution and for filling out the template so diligently! Can you please edit the title of this PR so that it briefly describes what the PR does? |
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.
Thanks for the PR!
To have your PR fit with the rest of our code base, please make the requested changes of:
- either removing the print statement or turning it into a log statement (first is preferred because logs can clutter downstream libraries)
- move the new test and group it with the other axline tests.
print(f"Calculated tolerance: {tolerance}") | ||
print(f"Calculated slope: {slope}") | ||
print(f"Y limits: {y_limits}") | ||
print(f"View limits: {vxlo}, {vylo}, {vxhi}, {vyhi}") |
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.
If you feel that this information is critical, please instead make it a logging message https://matplotlib.org/devdocs/devel/coding_guide.html#using-logging-for-debug-messages
But is this information useful now that you've fixed this bug?
@@ -0,0 +1,13 @@ | |||
import matplotlib |
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.
Instead of adding a new test file, please add another test to the axline tests
matplotlib/lib/matplotlib/tests/test_axes.py
Line 4977 in c010a36
@check_figures_equal() |
Hi @Andresporcruz are you still interested in working on this? |
Superseded by #28881. |
PR Summary
This PR fixes the issue where slopes less than 1E-8 were being set to 0 in the axline function. Adjusted the tolerance for np.isclose based on the view limits to handle small slopes accurately.
Detailed changes made to the
get_transform
method inlines.py
:Debug Print Statements:
Added print statements to output debug information such as the calculated tolerance, slope, y limits, and view limits. This helps trace the execution and verify the calculations.
Tolerance Adjustment for
np.isclose
:Adjusted the tolerance for
np.isclose
based on the current view limits. This ensures that the slope comparison takes into account the scale of the current view, allowing for more accurate handling of small slopes.Changes:
get_transform
method inlines.py
to adjust the tolerance fornp.isclose
based on the view limits.Here is a screenshot of the output I got:

Closes #28386
PR Checklist