-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
scatter() should not rescale if norm is given #15769
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
c61074d
to
c4b1e02
Compare
The same piece of code exists in imshow() (with the same doc as for scatter). Does it also need to be fixed there? |
c4b1e02
to
90468b0
Compare
There's a few others which may need the same treatment (haven't fully checked) -- hexbin, pcolor, pcolormesh, pcolorfast. Maybe worth extracting into a separate function? |
90468b0
to
f0e007c
Compare
This is now a private method The whole mappable initialization is a bit of a beast because the data are not part of the constructor and scaling depends on the data. Might be possible to untangle that further but that's for another PR. |
@@ -6341,10 +6330,9 @@ def pcolorfast(self, *args, alpha=None, norm=None, cmap=None, vmin=None, | |||
self.add_image(im) | |||
ret = im | |||
|
|||
if vmin is not None or vmax is not None: | |||
ret.set_clim(vmin, vmax) |
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 was actually a bug. it should have been inside the np.dim(C) == 2
because RGB(A) data also do not need a set_clim
.
Should the change in behavior (even if arguably a bugfix) be documented? |
f0e007c
to
813e3f1
Compare
Not sure. Do we document bugfixes? By their nature they change the behavior. But they are not an API change with respect to the intention. Usually people won't have to change their code because of that. If we want to document still, we should have a seprate bugfixes category. |
Actually, taking a step back... isn't this going to break people who are e.g. calling |
Yes. So to be defensive we want:
|
Actually, now that I think of it again, it seems a bit gratuitious to forbid |
I feel a bit different about My interpretation of a pure Side remark: |
I agree norm=(vmin, vmax) would have been nice but that ship has sailed. I guess I'm -0 on deprecating |
d2c7af2
to
eb42e75
Compare
I've decided to move forward with deprecating simultaneous use of norm and vmin/vmax. Let's see what others say. |
64685ac
to
c29df1b
Compare
Actually looking at this again (^2), if we want to go in this direction, perhaps (in a separate PR) we can indeed add support for norm=(vmin, vmax) and "soft-deprecate" vmin=..., vmax=...? (hide it behind kwargs, don't mention them in the main docs but only as an aside to the docs of norm?) |
I would support that direction, but that's definitively something for another PR. Also the name For this PR, let's just make the existing API behave consistently and match the documentation. |
c29df1b
to
031a0dc
Compare
Given that, I'm somewhat skeptical about disallowing |
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.
Deprecations are annoying, but so is an overly complicated API. I think that this cleanup is in the best long-term interest of mpl.
031a0dc
to
f5d9116
Compare
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.
Approving (modulo one minor nit that can be ignored), but I'll leave a few more days for others to comment (if any) because I'm only 95% sure it's a good idea :)
f5d9116
to
5a1a654
Compare
5a1a654
to
0a2f082
Compare
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.
can selfmerge postci
This is a case were we are going to have to be sensitive to any protest from users. Agree with @jklymak that deprecating |
Let's see if this deprecation causes user feedback. I'm not sure either if we finally want to deprecate |
FWIW |
@anntzer sure, but that is a bit annoying. This is one of those application vs library balance discussions (and I'm leaning towards the application side). |
Actually, one thing I had missed is that there's also already |
PR Summary
Fixes #14603.
The brings the behavior in line with thescatter
documentation:Also, when a norm is given, we shouldn't autoscale.Update: After discussion, the new behavior in this PR is #15769 (comment). Docs are updated accordingly.