-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: fallback to viewlims if no data #13588
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
This is a bug fix. Could be re-milestoned to 3.1 if it gets in soon... |
lib/matplotlib/axes/_base.py
Outdated
@@ -2430,6 +2430,12 @@ def handle_single_axis(scale, autoscaleon, shared_axes, interval, | |||
dl.extend(y_finite) | |||
|
|||
bb = mtransforms.BboxBase.union(dl) | |||
vl = mtransforms.BboxBase.union([ax.viewLim for ax in shared]) |
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.
Optional: Could maybe go into the if
.
Disadvantage: Would be duplicated for both ifs.
Advantage: Closer to the place of use. Gets only computed in the rare case that we need it (not that it would be a performance bottle neck.
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.
Put it in the if
and will only get computed once!
Flake8:
|
5c2d2f3
to
04ff86e
Compare
vl = mtransforms.BboxBase.union([ax.viewLim for ax in shared]) | ||
bb.intervalx = vl.intervalx | ||
if not np.isfinite(bb.intervaly).all(): | ||
if vl is None: |
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.
I would have just stupidly recalculated vl
. 😄 This only happens for the degenerate case that bb.intevalx
and bb.intervaly
contain non-finite values. IMHO preferable due to symmetry and simpler logic of the code.
04ff86e
to
740dda5
Compare
Rebased on master... |
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.
I don't like the amount of code, both old and new, required in this function to handle odd cases; but it looks like the new part here does what's needed, so it's better than nothing. Maybe @anntzer will see a way to clean it all up and replace a dozen lines with a pair.
Sorry, no magic available for you on this snippet right now :) |
…588-on-v3.1.x Backport PR #13588 on branch v3.1.x (FIX: fallback to viewlims if no data)
PR Summary
Closes #11337
The following test would fail because the view limit was set from 0-1:
The issue was in
autoscale_view
, which never checked the axes.viewLim, even if the data lim came back undefined. This PR checks the viewlim and uses that if the datalim is not finite.Note this issue is more generic than dates, but is most easily seen there because we can't have dates with ordinal values <1, and the default behaviour made it so such dates were the datalim.
PR Checklist