-
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Draft
AndrGutierrez
wants to merge
8
commits into
matplotlib:main
Choose a base branch
from
AndrGutierrez:bugfix-for-issue-29516
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+38
−2
Draft
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1909378
check xytext
AndrGutierrez 07130be
fix case xytext is None
AndrGutierrez 5623364
check_xytext finite
AndrGutierrez 5c979f8
raise ValueError for invalid xytext
AndrGutierrez f680e3f
fix transformation error
AndrGutierrez f64a90f
fix unbound coords
AndrGutierrez b03ea7b
fix support for units
AndrGutierrez 8cf348a
Update lib/matplotlib/text.py
AndrGutierrez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
check xytext
- Loading branch information
commit 190937839d810759d3459b3f862a2902227a444e
There are no files selected for viewing
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
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,10 @@ def get_tightbbox(self, renderer=None): | |
return super().get_tightbbox(renderer) | ||
|
||
|
||
def _check_xytext(self, renderer=None): | ||
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. I would put this method just after the |
||
"""Check whether the annotation at *xy_pixel* should be drawn.""" | ||
valid = True | ||
if all(isinstance(xyt, numbers.Number) for xyt in self.xytext): | ||
valid = not np.isnan(self.xytext).any() | ||
return valid | ||
_docstring.interpd.register(Annotation=Annotation.__init__.__doc__) |
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.
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.
If this is done it should be private. End users should not be accessing it.
But actually I think it would be cleaner to not set this and instead use
self.get_position()
within_check_xytext
.