Skip to content

scatter() fails on nan-containing input when providing edgecolor #14301

Closed

Description

@MaozGelbart

Bug report

Bug summary

Providing ax.scatter() with coordinates containing np.nan fails when providing edgecolor argument (but works when omitting it). Probably related to #12801 and #12422 introduced in 3.1.0, as it runs as expected with 3.0.3.

Code for reproduction

import matplotlib.pyplot as plt 
import numpy as np

fig, ax = plt.subplots()
x = [np.nan]
y = [0]
c = ['k']
ax.scatter(x, y, edgecolor=c)

Actual outcome

Traceback (most recent call last):
  File "D:\test.py", line 9, in <module>
    ax.scatter(x, y, edgecolor=c)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\__init__.py", line 1589, in inner
    return func(ax, *map(sanitize_sequence, args), **kwargs)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\axes\_axes.py", line 4490, in scatter
    alpha=alpha
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\collections.py", line 883, in __init__
    Collection.__init__(self, **kwargs)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\collections.py", line 128, in __init__
    self.set_edgecolor(edgecolors)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\collections.py", line 728, in set_edgecolor
    self._set_edgecolor(c)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\collections.py", line 712, in _set_edgecolor
    self._edgecolors = mcolors.to_rgba_array(c, self._alpha)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\colors.py", line 286, in to_rgba_array
    result[i] = to_rgba(cc, alpha)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\colors.py", line 177, in to_rgba
    rgba = _to_rgba_no_colorcycle(c, alpha)
  File "C:\ProgramData\Miniconda3\lib\site-packages\matplotlib\colors.py", line 238, in _to_rgba_no_colorcycle
    raise ValueError("Invalid RGBA argument: {!r}".format(orig_c))
ValueError: Invalid RGBA argument: masked

Expected outcome
Not to fail (and on this example, draw no points; just like without specifying edgecolor argument).

Matplotlib version

  • Operating system: Windows
  • Matplotlib version: 3.1.0
  • Matplotlib backend (print(matplotlib.get_backend())): Qt5Agg
  • Python version: 3.7.3
  • Jupyter version (if applicable):
  • Other libraries: numpy 1.16.3

Installed from conda-forge.

Activity

  1. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on May 24, 2019
  2. added this to the v3.1.1 milestone on May 24, 2019
  3. dstansby commented on May 24, 2019

    @dstansby
    Member

    This bisects to e959692 by @efiring - looks like another problem with using masked arrays.

  4. self-assigned this
    on May 24, 2019
  5. added a commit that references this issue on May 24, 2019
    dbf3eed
  6. stonebig commented on May 26, 2019

    @stonebig
    Contributor

    I suspect this has also broken seaborn . mwaskom/seaborn#1746 , as colors.py of matplotlib-master now works just fine.

    Would it be possible to get next week a matplotlib-3.1.1 ?

  7. efiring commented on May 26, 2019

    @efiring
    Member

    I think @tacaswell is planning a 3.1.1 release around the end of the month.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.status: confirmed bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions