Fix colorbar aspect when colorbar created, not its axes... by jklymak · Pull Request #22100 · matplotlib/matplotlib · GitHub
Skip to content

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

Closed
jklymak wants to merge 4 commits into
matplotlib:mainfrom
jklymak:fix-colrbar-aspect
Closed

jklymak wants to merge 4 commits into
matplotlib:mainfrom
jklymak:fix-colrbar-aspect

Conversation

@jklymak

@jklymak jklymak commented Jan 3, 2022

Copy link
Copy Markdown
Member

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

jklymak commented Jan 4, 2022

Copy link
Copy Markdown
Member Author

@jklymak

jklymak commented Jan 4, 2022

Copy link
Copy Markdown
Member Author

@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