-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
plt.scatter crashes because overwrites the colors to an empty list #12664
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
Bisects to #11383; also relevant #11373. The scatter documentation is rather clear
So I think it was never intended that |
See also #12021, I guess... |
I mess up the MWE. It was supposed to be this one: In [2]: import matplotlib.pyplot as plt
...: import numpy as np
...:
...: n_points = 4
...: xs = ys = zs = np.full(n_points, np.nan)
...: colors = list(np.full(n_points, 'k'))
...: plt.scatter(xs, ys, zs, c=colors)
...: plt.show() In that case, they are all the same and the tests passh. Which means that my MWE was wrong. I'll repoen if needed. |
Sorry it was needing to be 3D. import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D # noqa: F401 unused import
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
n_points = 4
xs = ys = zs = np.full(n_points, np.nan)
colors = list(np.full(n_points, 'k'))
ax.scatter(xs, ys, zs, c=colors)
plt.show() And this is the error: IndexError: index 0 is out of bounds for axis 0 with size 0 |
@ImportanceOfBeingErnest Sorry I mess up the snipped, I think that the error is related to #11373. Feel free to close if the issue is irrelevant. Sorry for the noise. |
Thx. |
Uh oh!
There was an error while loading. Please reload this page.
Bug report
Bug summary
When doing scatter plot of
nan
values it crashes because the list of colors gets overwriten to an empty list by this line:matplotlib/lib/mpl_toolkits/mplot3d/axes3d.py
Line 2317 in c921e2e
Code for reproduction
We hit this bug in mne-tools/mne-python#5676, but here is a MWE. Most probably this is a duplicated of #12641. In which case, this can be used as a test.
Expected outcome
(As in matplotlib 2.2.2) we would expect an empty plot with no error
Actual outcome
It breaks because cannot iterate over
c
The text was updated successfully, but these errors were encountered: