-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Build lognorm/symlognorm from corresponding scales. #16457
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
Conversation
lib/matplotlib/colors.py
Outdated
return functools.partial(_make_norm_from_scale, scale_cls, init=init) | ||
|
||
if init is None: | ||
init = lambda vmin=None, vmax=None, clip=False: None |
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.
the signature overriding mess is because the signatures of SymLogScale and SymLogNorm are not consistent with one another either...
See #16391 for related discussion and issues. Overall this seems like a great help to me. Hopefully if we have more norms in the future, authors will create a scale and just use this factory. Probably could do this for TwoSlopeNorm. |
The need for rebase comes from the deprecation that went into SymLogNorm re: base change, which the decorator obviously can't know about. I think trying to shoehorn the deprecation into the decorator is going to make things waaaay more complicated than needed, and we may just accept to have a fully separate SymLogNorm until the deprecation is resolved, keeping the decorator only for LogNorm for now. |
I guess. Or drop the deprecation warning. Based on the conversations, folks were using this qualitatively and might not complain about the base change. |
Let's pick one strategy or the other before I actually do the work of rebasing? :) |
#16404 is 3.2, so doing away w/ the deprecation should be fine for 3.3? |
Are we fine with breaking after just one release? |
I think it was broken before the fix so warning we are fixing a bug for one release seems generous. Ie the function didn’t do what it’s docstring said. |
OK, rebased. Still needs API changes note re: breakage. |
ba.apply_defaults() | ||
super().__init__( | ||
**{k: ba.arguments.pop(k) for k in ["vmin", "vmax", "clip"]}) | ||
self._scale = scale_cls(axis=None, **ba.arguments) |
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.
This looks great to me. For colorbar we will need access to self._scale
, which I assume this is where we get this.
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.
Yes.
Can you write the api break note? ;) |
|
I think we still have a todo wrt |
Looks like in #16404 you put the note for the addition of the base kwarg in the wrong file, it should have gone to api_changes_3.2.0/behavior.rst, not next_api_changes/behavior.rst (which is now for 3.3). Can you fix that first? |
https://github.com/matplotlib/matplotlib/pull/16541/files I moved it in the backport but have not done the v3.2.x -> master merge up yet. |
@tacaswell preferred bumping the removal to 3.4 (#17242 (comment)), so re-milestoning this PR accordingly. |
I'm going to try and fix-up symlognorm in #16376 - can I suggest that this PR just deals with LogNorm since we know that's mathematically correct at the moment? That way it will provide a good example of how to construct a norm from a scale, and I can handle symlognorm in one PR instead of having to track it over two different PRs. |
I'm fine with that, but can you first check that the |
Could you point out the bit of code you're referring to? I'm afraid I'm struggling to understand the new code here. |
All the logic relating to |
test_contour::test_contourf_log_extension has a tick move by one pixel, but actually looks better with the patch?
@anntzer I need help using the new
then |
OK, I figured it out - you need to specify an
works |
Just to be clear: This is because the order of parameters or even their default values is not the same between symlogscale and symlognorm, and there's no way to guess them (I could make assumptions about parameter order, e.g. everything goes before vmin/vmax/clip, but there's no way I could have autoguessed that for symlognorm, linthresh has no default whereas linscale defaults to 1 and base to 10; compare with symlogscale which has no default for any of them). So the solution I found was to just specify the defaults (and order) separately, via In reality it would be nice if the defaults of the scale and the norm could also be made consistent, but I sort of gave up on having any kind of consistency with symlog... |
yes, but the way it is now, just doing it all with default doesn't work. |
Yes, init is needed. The way the norm is inited is basically "pretend you call the |
Yeah, I think the docstring for |
Infer the (Sym)LogNorm math from the one in the corresponding scales. See #16375 for the need for it. (In my view, we probably could have done without norms at all, a norm is basically "just" a scale on the colorbar... anyways)
This fails test_colors.py::test_SymLogNorm because the old symlog norm
and scale were not consistent (as discussed extensively elsewhere -- this needs to be resolved in a way or another).
test_contour::test_contourf_log_extension fails due to a tick moving by 1px, but the new result actually looks nicer IMO.
PR Summary
PR Checklist