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

Improper handling of color in set_color when data contains NaN. #9891

Closed
@amicitas

Description

@amicitas

Bug report

Bug summary

When a scatter plot is made with data that contains np.nan (NaN), and then a color array is given usingset_color, the wrong colors get mapped to the data points.

Code for reproduction

frommatplotlibimportpyplotfrommatplotlib.colorsimportNormalizefrommatplotlibimportcmimportnumpyasnpx=np.linspace(0.0,1.0,50)y=np.linspace(0.0,1.0,50)norm=Normalize(0.0,1.0)colormap=cm.ScalarMappable(norm,'gnuplot')colors=colormap.to_rgba(y)# Expected colors with when x and y do not contain any np.nan.# Success.plot=pyplot.scatter(x,y,color=colors)pyplot.show()# Add some nan values.# If the color array is given during the initial creation of the# scatter plot, then everything works as expected.# Success.x[10:40]=np.nanplot=pyplot.scatter(x,y,color=colors)pyplot.show()# Again add some nan values.# If the color array is given as a call to set_color# then the colors no longer match the data.# Failure.x[10:40]=np.nanplot=pyplot.scatter(x,y)plot.set_color(colors)pyplot.show()

Actual outcome

Top: Expected colors with when x and y do not contain any np.nan.

Middle: Add some nan values. If the color array is given during the initial creation of the scatter plot, then everything works as expected.

Bottom: Again add some nan values. If the color array is given as a call toset_color then the colors no longer match the data.

screen shot 2017-11-30 at 15 19 02

Expected outcome

The colors corresponding to the data points should be displayed, even when data points contain NaN andset_color is used.

Matplotlib version

  • Operating system: OSX
  • Matplotlib version: 2.0.2
  • Matplotlib backend: module://ipykernel.pylab.backend_inline & MacOSX
  • Python version: 3.6.3
  • Jupyter Notebook version: 5.2.0
  • Other libraries: None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp