-
-
Notifications
You must be signed in to change notification settings - Fork 7.6k
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
Doc: use empty ScalarMappable for colorbars with no associated image. #16037
Conversation
This is consistent with the docstring of colorbar(), which explicitly suggests this approach; this would also later allow deprecating ColorbarBase, merging it into Colorbar.
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.
I prefer this, but won't merge just yet in case anyone was strongly wedded to ColorbarBase
for some reason.
(note that this was (somewhat) discussed in #3644) |
Added a second commit which replaces |
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.
From a usability point of view, creating a colorbar object directly seems simpler. Then again, we usually use factory functions and rarely instantiate objects directly in matplotlib.
From a design perspective, I'm not quite clear who owns the cmap and norm.
- If colormaps would not hold
cmap
andnorm
attributes but just query the associated mappable, the approach of this PR makes sense. - Looking at the code it seems that
ColorbarBase
actually manages it's owncmap
andnorm
.Colorbar
again copies these attributes from the mappable and tries to keep in sync viaon_mappable_changed
.
In the end, I'm +0.5 because it's already a documented recommendation and it paves the way for deprecating ColorbarBase
, and isolated colorbars are a more exotic feature, which is ok to be a bit more cumbersome.
…bars with no associated image.
…037-on-v3.2.x Backport PR #16037 on branch v3.2.x (Doc: use empty ScalarMappable for colorbars with no associated image.)
My plan is to make Colorbar.cmap and Colorbar.norm just properties returning the underlying mappable's cmap and norm, but that'll happen in the big ColorbarBase-deprecating PR. |
This is consistent with the docstring of colorbar(), which explicitly
suggests this approach; this would also later allow deprecating
ColorbarBase, merging it into Colorbar.
PR Summary
PR Checklist