8000 FIX: repositioning axes labels: use get_window_extent instead for spines. by jklymak · Pull Request #22301 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
8000

FIX: repositioning axes labels: use get_window_extent instead for spines. #22301

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

Merged
merged 1 commit into from
Jan 25, 2022

Conversation

jklymak
Copy link
Member
@jklymak jklymak commented Jan 24, 2022

PR Summary

Closes #22300

PR Checklist

Tests and Styling

  • Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • New features are documented, with examples if plot related.
  • New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • Documentation is sphinx and numpydoc compliant (the docs should build without error).

@jklymak jklymak marked this pull request as draft January 24, 2022 10:47
@jklymak jklymak added this to the v3.5.2 milestone Jan 24, 2022
@jklymak jklymak added topic: color/colorbar Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labels Jan 24, 2022
@@ -2081,8 +2081,9 @@ def _update_label_position(self, renderer):
if self.label_position == 'bottom':
try:
spine = self.axes.spines['bottom']
spinebbox = spine.get_transform().transform_path(
spine.get_path()).get_extents()
Copy link
Member Author

Choose a reason for hiding this comment

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

OK, so this is actually a behaviour change on bare axes. OTOH I think it is correct. get_path() will not include the ticks, whereas get_window_extent does. For axes with labels, this doesn't matter because the tick labels dominate. However, for an axes with no tick labels and long ticks, this spacing will be wrong.

Apparently we only test this in one spot, because it is a bit odd to label an axes with not tick labels...

Copy link
Member Author

Choose a reason for hiding this comment

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

Note in the changed image how the "ylabel" on the second axes has moved to the left a little bit.

Not sure if this is worth an API change note...

@jklymak jklymak force-pushed the fix-bad-spines-colorbar branch from 3f1cdb9 to c0a78bd Compare January 24, 2022 12:06
@jklymak jklymak marked this pull request as ready for review January 24, 2022 20:30
@QuLogic QuLogic merged commit 528745f into matplotlib:main Jan 25, 2022
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 25, 2022
QuLogic added a commit that referenced this pull request Jan 25, 2022
…301-on-v3.5.x

Backport PR #22301 on branch v3.5.x (FIX: repositioning axes labels: use get_window_extent instead for spines.)
@jklymak jklymak deleted the fix-bad-spines-colorbar branch January 25, 2022 07:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. topic: color/colorbar
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Saving a fig with a colorbar using a TwoSlopeNorm sometimes results in 'posx and posy should be finite values'
3 participants
0