-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
BUG: Fix text appearing far outside valid axis scale range #31061
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
base: main
Are you sure you want to change the base?
Changes from all commits
4ffb8d3
20103e7
371fcb2
d1bd978
bb9daee
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 |
|---|---|---|
|
|
@@ -1060,6 +1060,15 @@ def get_window_extent(self, renderer=None, dpi=None): | |
| bbox = bbox.translated(x, y) | ||
| return bbox | ||
|
|
||
| def get_tightbbox(self, renderer=None): | ||
| # Exclude text at data coordinates outside the valid domain of the axes | ||
|
Contributor
Author
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. if not self.get_visible() or self.get_text() == "":
return Bbox.null()I had originally included these lines, but they were changing a half dozen baseline images as plots expanded to fill space where there was empty/invisible text. Removed for now, but I think that's probably the right behavior and we can discuss including it.
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. If you think that might be important, you can target that change to the
Contributor
Author
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. Do you mean this PR or just that change?
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. The additional change, unless it's easier for you to do the whole PR.
Contributor
Author
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. Sure, I'll wait for this one to merge to avoid the |
||
| # scales (e.g., negative coordinates with a log scale). | ||
| if (self.axes | ||
| and self.get_transform() == self.axes.transData | ||
| and not self.axes._point_in_data_domain(*self.get_unitless_position())): | ||
| return Bbox.null() | ||
| return super().get_tightbbox(renderer) | ||
|
|
||
| def set_backgroundcolor(self, color): | ||
| """ | ||
| Set the background color of the text. | ||
|
|
||
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.
Is this not going to be used in 3D at some point (i.e., should it be passing in a tuple instead of individual coordinates)?
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.
This isn't currently called in any 3d path, since the rendering pipeline is so different. We might want to use it for something else, but I'm not too worried about future-proofing internal private functions beforehand.