Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

plt.scatter crashes because overwrites the colors to an empty list #12664

Closed
@massich

Description

@massich

Bug report

Bug summary
When doing scatter plot ofnan values it crashes because the list of colors gets overwriten to an empty list by this line:

xs,ys,zs,s,c=cbook.delete_masked_points(xs,ys,zs,s,c)

Code for reproduction
We hit this bug inmne-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.

importmatplotlib.pyplotaspltimportnumpyasnpn_points=4xs=ys=zs=np.full(n_points,np.nan)colors=list(np.full(2,'k'))plt.scatter(xs,ys,zs,c=colors)plt.show()

Expected outcome

(As in matplotlib 2.2.2) we would expect an empty plot with no error

In [25]: matplotlib.__version__Out[25]:'2.2.2'In [26]: %pasteimport matplotlib.pyplot as pltimport numpy as npn_points = 4xs = ys = zs = np.full(n_points, np.nan)colors = list(np.full(2,'k'))plt.scatter(xs, ys, zs, c=colors)plt.show()## -- End pasted text --In [27]:

Actual outcome
It breaks because cannot iterate overc

In [9]: matplotlib.__version__Out[9]:'3.0.1'In [10]: %pasteimport matplotlib.pyplot as pltimport numpy as npn_points = 4xs = ys = zs = np.full(n_points, np.nan)colors = list(np.full(2,'k'))plt.scatter(xs, ys, zs, c=colors)plt.show()## -- End pasted text --Traceback (most recent call last):  File"<ipython-input-10-f59e87d45c38>", line 7,in<module>    plt.scatter(xs, ys, zs, c=colors)  File"/home/sik/miniconda3/envs/mne/lib/python3.6/site-packages/matplotlib/pyplot.py", line 2864,in scatter    is not Noneelse {}),**kwargs)  File"/home/sik/miniconda3/envs/mne/lib/python3.6/site-packages/matplotlib/__init__.py", line 1805,in innerreturn func(ax,*args,**kwargs)  File"/home/sik/miniconda3/envs/mne/lib/python3.6/site-packages/matplotlib/axes/_axes.py", line 4234,in scatter    .format(nc=n_elem, xs=x.size, ys=y.size)ValueError:'c' argument has 2 elements, which is not acceptablefor use with'x' with size 4,'y' with size 4.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp