Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix colorbar aspect when colorbar created, not its axes... #22100

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

Closed
wants to merge 4 commits into from

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Jan 3, 2022

PR Summary

Closes #22087 (?)

Creating a colorbar axes and then subsequently setting its aspect ratio after creation, but before creating the colorbar, failed after #20501. That is because the new colorbar logic consults cax._colorbar_info for the aspect ratio of the colorbar, and we were setting that when the colorbar axes was created. Here we change the logic so the aspect ratio is not set until the colorbar is put into the axes.

#22087 is still broken in that users used to be able to set the aspect ratio via cax.set_aspect, whereas now we are using cax.set_box_aspect. That could maybe be fixed.

We probably should also allow a way for colorbars to reset their aspect ratio (#20588).

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 4, 2022 09:40
@jklymak
Copy link
Member Author

jklymak commented Jan 4, 2022

This logic also fails, because we modify the box_aspect as part of the algorithm to shrink the axes for extend triangles. So if we redraw, we keep making the colorbar aspect smaller and smaller!

@jklymak
Copy link
Member Author

jklymak commented Jan 4, 2022

I think the proper solution here is that colorbar needs to know its aspect ratio, and that the user cannot control the underlying axes aspect ratio directly. I think that can mostly work now, but we would need to grow a colorbar.set_aspect method for post-facto aspect changes like @efiring wants to do.

@jklymak jklymak closed this Jan 4, 2022
@jklymak jklymak deleted the fix-colrbar-aspect branch January 4, 2022 13:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: aspect ratio control of colorbar Axes fails.
1 participant