| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good.
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good. Can you please add a note to the docstring of set_norm that it will reset the formatter and locator?
Sorry, something went wrong.
|
This looks good! Thanks a lot for the detailed explanation. It made reviewing much faster. |
Sorry, something went wrong.
|
OK, note added, though its a bit of a funky place to add a note about colorbar changes.... |
Sorry, something went wrong.
| Notes | ||
| ----- | ||
| If there are any colorbars using the mappable for this norm, setting | ||
| the norm of the mappable will reeset the norm, locator, and formatters |
There was a problem hiding this comment.
Typo.
| the norm of the mappable will reeset the norm, locator, and formatters | |
| the norm of the mappable will reset the norm, locator, and formatters |
Sorry, something went wrong.
True, but better than nothing and I don't have a better solution. |
Sorry, something went wrong.
There was a problem hiding this comment.
LGTM!
I went ahead and fixed the small PEP8 error that made the tests fail.
Sorry, something went wrong.
|
@jklymak I screwed up and didn't fix all the PEP8 from the github text editor… Do you mind fixing the rest (and maybe rebasing to squash the PEP8 fixes commits altogether?) |
Sorry, something went wrong.
|
Thanks for the review @NelleV. But this is still a WIP. I mucked around with so much it needs a thorough cleaning now. In particular for each colorbar draw_all is called three times which is unacceptable! |
Sorry, something went wrong.
Stale! Sorry for the extra work!
|
I think this is ready for now, but pinging @LevN0 Note that I decided we don't need to make locator and formatter properties, so I took that out to make things more straight forward... |
Sorry, something went wrong.
| self.outline = None | ||
| self.patch = None | ||
| self.dividers = None | ||
| # self.locator and self.formatter are properties... |
There was a problem hiding this comment.
this comment is not true anymore, I think.
Sorry, something went wrong.
|
|
||
| def set_norm(self, norm): | ||
| """ | ||
| set the norm of the mappable associateed with this colorbar. |
There was a problem hiding this comment.
| set the norm of the mappable associateed with this colorbar. | |
| Set the norm of the mappable associated with this colorbar. |
Sorry, something went wrong.
| by :func:`colorbar_factory` and should not be called manually. | ||
|
|
||
| """ | ||
| _log.debug('mappable changed') |
There was a problem hiding this comment.
| _log.debug('mappable changed') | |
| _log.debug('colorbar mappable changed') |
Giving slightly more context helps understanding the log output.
Sorry, something went wrong.
| have been customized, they will need to be customized again. | ||
| """ | ||
|
|
||
| _log.debug('update normal') |
There was a problem hiding this comment.
| _log.debug('update normal') | |
| _log.debug('colorbar update normal') |
Giving slightly more context helps understanding the log output.
Sorry, something went wrong.
| assert isinstance(cbar.locator, _ColorbarLogLocator) | ||
| assert np.allclose(cbar.ax.yaxis.get_majorticklocs(), | ||
| np.logspace(-8, 5, 14)) | ||
| # note that that set_norm reemoves the FixedLocator... |
There was a problem hiding this comment.
| # note that that set_norm reemoves the FixedLocator... | |
| # note that set_norm removes the FixedLocator |
Sorry, something went wrong.
|
|
||
|
|
||
| def test_colorbar_format(): | ||
| # make sure that format is passed properly.... |
There was a problem hiding this comment.
| # make sure that format is passed properly.... | |
| # make sure that format is passed properly |
Sorry, something went wrong.
|
Sorry for the WIP embargo and confusion that caused. Most of the issues identified in #13228 have been addressed and this is ready for a second review. |
Sorry, something went wrong.
|
Is there a way to directly merge @timhoffm 's suggestion? |
Sorry, something went wrong.
|
I think this is ready again:
|
Sorry, something went wrong.
Sorry, something went wrong.
There was a problem hiding this comment.
It would be good to remove the reference to ScalarMappable inheritance in the tutorial:
https://matplotlib.org/tutorials/colors/colorbar_only.html#sphx-glr-tutorials-colors-colorbar-only-py
Sorry, something went wrong.
| Private class to hold deprecated ColorbarBase methods that used to be | ||
| inhereted from ScalarMappable. | ||
| """ | ||
| @cbook.deprecated("3.1", alternative="mappable.set_norm") |
There was a problem hiding this comment.
For alternative, did you mean ScalarMappable.set_norm here, as below?
Sorry, something went wrong.
There was a problem hiding this comment.
Fixed both points! Thanks,
Sorry, something went wrong.
|
This is technically an API change, but hopefully not a controversial one (the inheritance from ScalarMappable didn't really work properly anyways...) |
Sorry, something went wrong.
|
Did anyone else have time to look at this again? Changes from previous approvals are here (squashed and rebased) |
Sorry, something went wrong.
FIX: stop colorbar from being a ScalarMappable, and deprecate common fcns FIX: allow norm limit to change and not change user-set ticks and format FIX: moved old ScalarMappable methods to a private method DOC: fix deprecation and tutorial DOC: api note
|
Probably not addressed to me, but I looked at it again to confirm it still addresses the original issue, and it does. |
Sorry, something went wrong.
There was a problem hiding this comment.
Looks good to me! I've added two minor comments on docstrings.
Sorry, something went wrong.
|
Thanks! |
Sorry, something went wrong.
|
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
$ git checkout v3.0.x $ git pull
$ git cherry-pick -m1 ce33de7afedbb2250a11aa102ba9f6996f6c259e
$ git commit -am 'Backport PR #13234: FIX: allow colorbar mappable norm to change and do right thing'
git push YOURFORK v3.0.x:auto-backport-of-pr-13234-on-v3.0.x
And apply the correct labels and milestones. Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon! If these instruction are inaccurate, feel free to suggest an improvement. |
Sorry, something went wrong.
…anged FIX: allow colorbar mappable norm to change and do right thing
The dummy parent class introduced in matplotlib#13234 had a `set_clim` with a different signature to the version in `ScalarMappable`. This caused code which called it and passed both arguments to fail, rather than simply no-op.
| Back | FazBrowse Home | New Git URL |
PR Summary
Closes #13228
Before
Note this colorbar is simply wrong...
After
Changing norm erases colorbar formatter and locator...
If the norm is changed, then any formatter and locator settings are also lost. This is new behaviour, but I think reasonable if the user has changed the norm. Here we illustrate this just by setting the ticks (which changes the Locator to FixedLocator). Note that when the norm is set the locator goes back to the automatic locator.
Next issue: Reset scale if norm changes...
The axis scale wasn't being reset if the norm changed, but it needs to be reset as well...
Before
After
I'm marking WIP until @LevN0 lets us know we squashed all the bugs...
Next Issue: format='%1.4e' now works...
See new test...
PR Checklist