Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Fix colorbar alignment with suptitle in compressed layout mode#30766
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation
miriamsimone commentedNov 20, 2025
closing and reopening to rerun tests |
miriamsimone commentedNov 21, 2025
maybe someone can help me with getting the tests to pass? |
timhoffm commentedNov 21, 2025
You can ignore the failing tests here. They are known to be flaky. |
timhoffm commentedNov 21, 2025
miriamsimone commentedNov 22, 2025
jklymak commentedNov 23, 2025
This looks good, but please fix the linting errors! |
miriamsimone commentedNov 24, 2025
fixed linting errors |
| @image_comparison(['test_compressed_supylabel_colorbar.png'],style='mpl20') | ||
| deftest_compressed_supylabel_colorbar(): | ||
| """ | ||
| Test that horizontal colorbars align with axes |
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.
Linting is still mad about the trailing white space here.
Uh oh!
There was an error while loading.Please reload this page.
dcff41f intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
jklymak commentedNov 27, 2025
Thanks for sorting this out@miriamsimone ! |


PR summary
closes#30472
This PR fixes a colorbar alignment issue when using compressed layout mode
with suptitle. In compressed layout, when
apply_aspect()is called onaxes (triggered by the presence of a suptitle), colorbars were not
properly aligning with their parent axes because they were being sized
based on the pre-aspect-adjustment dimensions.
Why is this change necessary?
When using
layout='compressed'with a suptitle, the axes undergo aspectratio adjustments that change their visual height. Colorbars attached to
these axes were not accounting for this adjustment, resulting in
misaligned colorbars that didn't match their parent axes' vertical extent.
What problem does it solve?
Colorbars now properly align with their parent axes in compressed layout
mode, maintaining the same height and vertical position even when the
parent axes have been resized by aspect ratio constraints.
What is the reasoning for this implementation?
The fix passes a
compressflag through the repositioning chain and, whenin compressed mode with single-parent vertical colorbars, uses the actual
post-aspect-adjustment position of the parent axis to calculate the
colorbar's bounding box. This ensures the colorbar dimensions match the
visually rendered parent axes rather than the pre-adjustment layout grid
dimensions.
Example:
PR checklist
issue
release note