-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Passing an incorrectly sized colour list to scatter should raise a relevant error #11373
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 also ran into this (but did not take the time to track it down) yesterday. Running through |
Easiest fix would be doing |
Maybe it's worth mentioning that the same error is also shown when a nonexisting color is specified, i.e.
results in When using
which is of course better than what is currently raised, but doesn't really tell the user that the color they used does not exist. |
Given that #11383 is merged, this issue can be closed. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug summary
When calling a
scatter
with a list for thec
argument, which does not match the length of the data, anAttributeError: 'list' object has no attribute 'shape'
is raised instead of informing the user about the non-matching length issue.#7363 tried hard to make error message clearer but forgot to consider that input may be any sequence, not necessarily a numpy array.
A similar issue was raised in #9209.
Code for reproduction
Actual outcome
An error
This error tells nothing about the true cause of the problem, but is rather an error caused by the error message itself.
Expected outcome
An error similar to the intended one
matplotlib/lib/matplotlib/axes/_axes.py
Lines 3946 to 3950 in 6ec80ea
but for a list, which does not have a
shape
attribute.Note that I rather raised this issue, instead of directly fixing it, because I'm not sure if there should be some typechecking performed within the
except
clause or whether to add anothertry
inside theexcept
or - because both feels kind of strange - someone has an even better idea.Matplotlib version
The text was updated successfully, but these errors were encountered: