Repository navigation
adding check_xytext for NaN values #30381
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
Changes from 3 commits
1909378
07130be
5623364
5c979f8
f680e3f
f64a90f
b03ea7b
8cf348a
a80baa2
48559ca
45bea11
ddfa661
f5452a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import functools | ||
| import logging | ||
| import math | ||
| import numbers | ||
| from numbers import Real | ||
| import weakref | ||
|
|
||
|
|
@@ -1862,6 +1863,7 @@ def transform(renderer) -> Transform | |
| xy, | ||
| xycoords=xycoords, | ||
| annotation_clip=annotation_clip) | ||
| self.xytext = xytext | ||
| # warn about wonky input data | ||
| if (xytext is None and | ||
| textcoords is not None and | ||
|
|
@@ -2027,7 +2029,12 @@ def draw(self, renderer): | |
| # docstring inherited | ||
| if renderer is not None: | ||
| self._renderer = renderer | ||
| if not self.get_visible() or not self._check_xy(renderer): | ||
|
|
||
| visible = (self.get_visible() and | ||
| self._check_xy(renderer) and | ||
| self._check_xytext()) | ||
|
|
||
| if not visible: | ||
| return | ||
| # Update text positions before `Text.draw` would, so that the | ||
| # FancyArrowPatch is correctly positioned. | ||
|
|
@@ -2046,7 +2053,10 @@ def get_window_extent(self, renderer=None): | |
| # docstring inherited | ||
| # This block is the same as in Text.get_window_extent, but we need to | ||
| # set the renderer before calling update_positions(). | ||
| if not self.get_visible() or not self._check_xy(renderer): | ||
| visible = (self.get_visible() and | ||
| self._check_xy(renderer) and | ||
| self._check_xytext()) | ||
| if not visible: | ||
| return Bbox.unit() | ||
| if renderer is not None: | ||
| self._renderer = renderer | ||
|
|
@@ -2072,4 +2082,13 @@ def get_tightbbox(self, renderer=None): | |
| return super().get_tightbbox(renderer) | ||
|
|
||
|
|
||
| def _check_xytext(self, renderer=None): | ||
|
AndrGutierrez marked this conversation as resolved.
Resolved
|
||
| """Check whether the annotation at *xy_pixel* should be drawn.""" | ||
| valid = True | ||
| if self.xytext is None: | ||
| return valid | ||
|
|
||
| if all(isinstance(xyt, numbers.Number) for xyt in self.xytext): | ||
| valid = not np.isnan(self.xytext).any() and np.isfinite(self.xytext).all() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To fix the polar case, you need to check these values after they are transformed to "screen space", for which you can use I'm not really sure if invalid values here should make the annotation invisible or raise a more helpful error message. |
||
| return valid | ||
| _docstring.interpd.register(Annotation=Annotation.__init__.__doc__) | ||
Uh oh!
There was an error while loading. Please reload this page.