8000 If text location isn't finite, set it to not visible by dstansby · Pull Request #7880 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

If text location isn't finite, set it to not visible #7880

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 2 commits into from

Conversation

dstansby
Copy link
Member

This fixes #6789. The problem was there was some text at +/- inf locations, which mean that when the tight_layout calculation was being done an inf was being passed through.

I think it's reasonable to set text with co-ordinates that aren't finite to not visible as I presume it'll never be seen, although this currently just hides the problem without a warning or error. Perhaps this should raise a warning or error too? Thoughts appreciated!

@anntzer
Copy link
Contributor
anntzer commented Jan 22, 2017

Can the issue at #6789 also be triggered by e.g. patches at nonfinite positions? It feels like the logic of ignorining nonfinite positions should go into tight_layout itself instead (having thought approximately for 5s about the issue, so I may completely wrong).

@@ -1154,6 +1154,8 @@ def set_position(self, xy):
"""
self.set_x(xy[0])
self.set_y(xy[1])
if not np.all(np.isfinite(xy)):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will act as a latch and this text will awlays be invisible

@tacaswell tacaswell added this to the 2.1 (next point release) milestone Jan 22, 2017
@dstansby
Copy link
Member Author

@anntzer I think you're probably right (although will text at +/- infinity ever be shown?). I'll have another dig and try and fix #6789 in tight_layout soonish.

@anntzer
Copy link
Contributor
anntzer commented Jan 23, 2017

I guess you could have a scale that brings infinity to a finite value? :-) (although that would probably crash other parts of mpl)
The point of the suggestion is to fix the issue at its root (i.e. tight_layout, if I understand correctly), not on an artist-by-artist basis.

@dstansby
Copy link
Member Author

Closing this, since the eventual fix will be different. If anyone else wants to pick this up feel free.

@dstansby dstansby closed this Jan 28, 2017
@dstansby dstansby deleted the inf-label-visibility branch January 28, 2017 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tutorial pyplot_scales.py crashes when used with plt.tight_layout()
3 participants
0