8000 Fix `axline` for slopes < 1E-8 by Andresporcruz · Pull Request #28431 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

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

Closed
wants to merge 3 commits into from

Conversation

Andresporcruz
Copy link
@Andresporcruz Andresporcruz commented Jun 20, 2024

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 in lines.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:

  • Modified the get_transform method in lines.py to adjust the tolerance for np.isclose based on the view limits.

Here is a screenshot of the output I got:
image

Closes #28386

PR Checklist

Copy link
@github-actions github-actions bot left a 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.

@story645
Copy link
Member

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?

@story645 story645 added the PR: bugfix Pull requests that fix identified bugs label Jun 20, 2024
Copy link
Member
@story645 story645 left a 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.

Comment on lines +1526 to +1529
print(f"Calculated tolerance: {tolerance}")
print(f"Calculated slope: {slope}")
print(f"Y limits: {y_limits}")
print(f"View limits: {vxlo}, {vylo}, {vxhi}, {vyhi}")
Copy link
Member

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
Copy link
Member

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

@check_figures_equal()

@rcomer
Copy link
Member
rcomer commented Aug 2, 2024

Hi @Andresporcruz are you still interested in working on this?

@QuLogic QuLogic modified the milestones: v3.9.2, v3.9.3 Aug 12, 2024
@rcomer rcomer changed the title My contribution Fix axline for slopes < 1E-8 Aug 19, 2024
@QuLogic
Copy link
Member
QuLogic commented Sep 28, 2024

Superseded by #28881.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
PR: bugfix Pull requests that fix identified bugs status: orphaned PR status: superseded
Projects
Status: Waiting for author
Development

Successfully merging this pull request may close these issues.

[Bug]: Minor issue - Drawing an axline sets slopes less than 1E-8 to 0
5 participants
0