Skip to content

Fix issue with space allocated for single tick that should not be there #24262

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
Dec 21, 2022

Conversation

oscargus
Copy link
Member

@oscargus oscargus commented Oct 24, 2022

Co-authored-by: Antony Lee anntzer.lee@gmail.com

PR Summary

Closes #18804

Do not take ticks into account if there are no ticks drawn when determining the extent of the spine.

Helps with #16981 (actually looks quite OK, possibly closes it, but #18804 (comment) claims it doesn't, at least not at that time).

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).

@oscargus oscargus marked this pull request as ready for review October 24, 2022 15:40
@oscargus
Copy link
Member Author

The benefit of keeping the space there is that it provides a bit of space for the labels.

Expected:
colorbar_keeping_xlabel-expected

Now:
colorbar_keeping_xlabel

I guess the bug it fixes is more relevant though and this is just a "co-incident" that it looks better with the old approach.

@jklymak
Copy link
Member

jklymak commented Oct 25, 2022

Can this PR get a bit more documentation - the all-black test doesn't help me understand what is going on, and the use of "Expected" and "now" above is ambiguous, and could use some test code to understand what was done and why. Thanks!

@jklymak jklymak added the status: needs clarification Issues that need more information to resolve. label Oct 25, 2022
@oscargus
Copy link
Member Author

oscargus commented Oct 25, 2022

I think I'll have to ask @anntzer for a proper explanation as I just implemented his patch. For now, I'll have to refer to the issue it closes.

In current main, there is a thin white line to the left and below the figure:
foo

The "expected" image is the current test image. The "now" image is the result after this change.

My interpretation is that we remove some non-visible ticks from the size calculation which gets rid of the white stripes but also breaks the nice looking alignment on the x-label for the color bar.

Edit: reading the code I've updated the description based on what I believe happens (at least on a higher level, there is a bit of Python magic that I do not really follow).

@anntzer
Copy link
Contributor

anntzer commented Oct 29, 2022

Your interpretation is correct. The first part of the patch skips any handling of the axis if it is not visible. The second part filters the visible ticks, and includes only the first visible major tick (if any) and the first visible minor tick (if any) into the bbox calculation.

@tacaswell tacaswell added this to the v3.7.0 milestone Nov 3, 2022
Co-authored-by: Antony Lee <anntzer.lee@gmail.com>
@oscargus oscargus removed the status: needs clarification Issues that need more information to resolve. label Nov 4, 2022
@oscargus oscargus added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Dec 15, 2022
@ksunden ksunden merged commit 9f3c6f4 into matplotlib:main Dec 21, 2022
@oscargus oscargus deleted the tickspinefix branch December 21, 2022 23:17
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

bugged pads on savefig
5 participants