-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Inconsistent shape handling of parameter c compared to x/y in scatter() #12735
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
Comments
(I think we should just reject (with deprecation, yada yada) any non-1D input (and yes, that includes (n, 1) and (1, n) input).) |
The |
I dunno - it all seems pretty inconsistent to me, like whoever wrote plt.plot(np.arange(12).reshape(3, 4), np.arange(12).reshape(3, 4))
plt.scatter(np.arange(12).reshape(3, 4), np.arange(12).reshape(3, 4)) are pretty shockingly different. I'm fine w/ them being different, but I'm somewhat against |
If they were the same thing we wouldn't need both. They are intentionally different. Where their purposes overlap, we recommend using |
Still we should aim at consistent API where possible. I don't see an argument for different handling of mutl-dimensional data
|
In scatter,
|
@efiring Thanks for the clarification. I forgot about the more "sophisticated" I also see that consistent handling of Given that, I still support @anntzer's suggestion to deprecate any non-1D input to |
I disagree. Relative to #13959, I don't think that removing the flattening makes anything substantially simpler or more consistent. It would break existing code for no gain that I can see, and would require adding shape checking in place of size checking. Really, what is the big gain here, to motivate a considerable break in backward compatibility? I just don't see it. (And removing the flattening does not remove differences between If we were starting from scratch, and if we took the point of view that we should keep the API as simple as possible and leave it to the user to make their data fit that API, then it might make sense to require that |
Reconsidered. Actually, it can be reasonable to support 2D arrays as scatter input. For some kinds of scatter plots x and y can be semantically the same type e.g. positions in a plane (as opposed to y = f(x)). And if these are aligned on a regular grid, a 2D shape may be the natural form of the input data. |
Bug report
As described in #11663 (review):
Something funny is going on here (I know it was already there before, but still seems worth pointing out): we take x and y of any shapes and flatten them (they just need to have the same size), but
c
has to match either the shape ofx
ory
, not just the size.In other words the following "work" (i.e. perform an implicit ravel()):
but the following fail:
Of course that last one has the best error message (irony intended):
The text was updated successfully, but these errors were encountered: