-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: don't include text at -inf in bbox #11404
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
lib/matplotlib/axis.py
Outdated
bb.append(a.get_window_extent(renderer)) | ||
x, y = a.get_position() | ||
if np.isfinite(x) and np.isfinite(y): | ||
bb.append(a.get_window_extent(renderer)) |
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.
Spent ~2s thinking about this but in general wouldn't it be better to first get the bbox and then include it only if it is finite? Or does the exception occur in get_window_extent? (in which case I'd argue it should be fixed there)
In fact perhaps get_window_extend should return a null bbox (do we even have a way to represent that) in that case, to avoid having to special-case it again and again. Or perhaps not (again, just throwing in some comments).
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.
Good point.
However, I don't think the API allows returning a None
for the window extent, so we'll have to check the dims of the bbox are reasonable w/o an API change
4fd7998
to
9326553
Compare
There is still something wrong with the logit axis transform that causes _update_label_position to get put at infinity as @frederik-1 said. Setting the label for logit axis never works which is really the bug. Nonetheless this symptom patch is still probably a good idea. |
With master I am not able to reproduce the problem using the test case you provide:
Do we still need this PR? Or is the original problem fixed by #11417? |
We don’t need it to fix the proximate problem anymore but it can’t hurt to check the box has width and height before appending it. |
PR Summary
Adresses #11386, #5456. See also #11417 that properly fixes the logit issues...
Code like below caused anything that required the
tightbbox
of the axes to fail forlogit
axes:This PR does not fix logit axes, but instead ignores non-finite values of the text positions when calculating the bbox, since those are assumed to be invalid. I suppose someone could also figure out how to fix logit, but I'm not too interested in digging into it.
Before
After
PR Checklist
< 8000 li class="task-list-item"> Has Pytest style unit tests- Code is PEP 8 compliant
- New features are documented, with examples if plot related
- Documentation is sphinx and numpydoc compliant
- Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
- Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way