Fix errorbar autoscaling inconsistency on log axes (fixes #31462)#31478
Open
Vikash-Kumar-23 wants to merge 4 commits intomatplotlib:mainfrom
Open
Fix errorbar autoscaling inconsistency on log axes (fixes #31462)#31478Vikash-Kumar-23 wants to merge 4 commits intomatplotlib:mainfrom
Vikash-Kumar-23 wants to merge 4 commits intomatplotlib:mainfrom
Conversation
rcomer
reviewed
Apr 9, 2026
jklymak
approved these changes
Apr 13, 2026
timhoffm
reviewed
Apr 13, 2026
Member
|
I recommend installing the pre-commit hooks to help with the linting |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
closes #31462
This PR fixes an autoscaling inconsistency for
errorbaron log-scaled axes by addressing a root-cause bug inCollection.get_datalim.Why this change is necessary
When log scale is set before calling
errorbar, autoscaling can produce incorrect lower limits (often collapsing near 1).If
errorbaris called first and log scale is applied afterward, the limits are correct.This order-dependent behavior is unexpected and inconsistent.
What this PR changes
As suggested by maintainers in the review, the root cause was traced to
Collection.get_datalim.When calculating limits on log axes,
transform.get_affine() - transDatayields an inverse non-affine (inverse log) component. However, this was being passed to the C wrapper (_path_wrapper.cpp), which only accepts affine matrices. The non-affine part was completely discarded at the C boundary, causing extents to be computed in log-transformed coordinates instead of original data coordinates.To fix this:
Before fix (incorrect behavior)
scale → errorbarAfter fix (correct behavior)
Minimum self-contained example
Expected after this PR
AI Disclosure
AI tools were used to assist in drafting text and suggesting validation scenarios.
All code changes, final implementation decisions, and verification were done manually.
PR checklist