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

Issue when setting scatter color in separate method call #10381

Closed
Milestone
@astrofrog

Description

@astrofrog

For an application I am developing, I need to callax.scatter then change the colors of the points after the fact. However, if the input x/y values contain NaN values, then setting the colors after the fact doesn't work properly. The following example:

importmatplotlibmatplotlib.use('Agg')importnumpyasnpimportmatplotlib.pyplotaspltfig=plt.figure()ax=fig.add_subplot(1,1,1,aspect='auto')x=np.array([1,2,3])y=np.array([2,np.nan,4])c=np.array([3,4,5])s=ax.scatter(x,y,c=c,vmin=3,vmax=5,s=320,zorder=1,edgecolor='none')s=ax.scatter(x,y,s=160,zorder=2,edgecolor='none')s.set_array(c)s.set_clim(3,5)s=ax.scatter([], [],s=40,zorder=3,edgecolor='none')s.set_offsets(np.vstack([x,y]).transpose())s.set_array(c)s.set_clim(3,5)fig.savefig('test.png')

produces the following output:

test

The top right point should be all yellow. However it isn't, because in thescatter call, invalid values are removed, so when I try and set the colors withset_array, the color values are offset from the x/y values. In the final case, things work since the 'bad' values are masked from neither the offsets nor the colors.

Is there a way to achieve something along the lines of the middle example (setting the colors after the fact)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp