Factor out handling of missing spines in alignment calculations.#28313
Merged
timhoffm merged 1 commit intomatplotlib:mainfrom May 27, 2024
Merged
Factor out handling of missing spines in alignment calculations.#28313timhoffm merged 1 commit intomatplotlib:mainfrom
timhoffm merged 1 commit intomatplotlib:mainfrom
Conversation
rcomer
approved these changes
May 27, 2024
This comment was marked as outdated.
This comment was marked as outdated.
timhoffm
approved these changes
May 27, 2024
Member
timhoffm
left a comment
There was a problem hiding this comment.
Take or leave my comments. You can self-merge.
lib/matplotlib/axis.py
Outdated
| # that have been set by `fig.align_xlabels()` | ||
| bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer) | ||
|
|
||
| ax = self.axes |
Member
There was a problem hiding this comment.
This is only extracted to make l.2409 / l.2414 shorter. I would not do that because it separates definition and usage and thereby results in more state and thus cognitive load.
I slightly prefer to either leave this in place self.axes.spines.get("bottom", self.axes) - or if that's reads too cumbersome, define it right before usage in each if branch.
Contributor
Author
There was a problem hiding this comment.
I think the repetition of self.axes reads a bit cumbersome here, but sure, I put it back. Ditto below.
lib/matplotlib/axis.py
Outdated
| # get bounding boxes for this axis and any siblings | ||
| # that have been set by `fig.align_ylabels()` | ||
| bboxes, bboxes2 = self._get_tick_boxes_siblings(renderer=renderer) | ||
| ax = self.axes |
... by using spines.get. Note that for an Axes, get_window_extent (with or without the renderer argument) is always equal to ax.bbox; the refactoring also makes that symmetry clearer.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
... by using spines.get.
Note that for an Axes, get_window_extent (with or without the renderer argument) is always equal to ax.bbox; the refactoring also makes that symmetry clearer.
Noted while looking at #28300.
PR summary
PR checklist