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

changed method on PathCollection may revert set_color #13131

Open
@stippingerm

Description

@stippingerm

Bug report

Bug summary

When a PathCollection is created (e.g. by a scatter plot) using an array of scalars to be colormapped on it then thechanged() method reverts the effect of previously issuedset_facecolor command thusset_facecolor does not work as expected. (As a consequenceset_color() deos not work as expected either.)

Code for reproduction

importmatplotlib.pyplotaspltdefmake_fig():fig,ax=plt.subplots(1,2,figsize=(6,2))sc0=ax[0].scatter([0,0,1],[0,1,0],c=(1,2,3),linewidths=3,alpha=None)ax[0].set_title('Colormapped scalar')# underlying ScalarMappable mixin is usedsc1=ax[1].scatter([0,0,1],[0,1,0],c=['r','g','b'],linewidths=3,alpha=None)ax[1].set_title('Indiv color definition')returnfig,ax,sc0,sc1fig,ax,sc0,sc1=make_fig()sc0.set_facecolor([[1,0,0,0.1],[1,0,0,0.5],[1,0,0,0.9]])sc0.changed()# unexpected behavior heresc1.set_facecolor([[1,0,0,0.1],[1,0,0,0.5],[1,0,0,0.9]])sc1.changed()# unexpected behavior here

Actual outcome

mpl_color_bug1

Expected outcome

The same shades of red shall appear on the left panel that are displayed on the right.

Note: without thechanged() calls everything is OK.set_facecolor correctly changes both face and edge color and alpha for individual colors and for colormapped scalar too.
But then, thechanged() method reverts all changes for colormapped scalars Most probablyset_facecolor does not correctly update some property telling that new colors are not derived from scalar values anymore.

Additional nuissances

fig,ax,sc0,sc1=make_fig()sc0.set_color([[1,0,0,0.1],[1,0,0,0.5],[1,0,0,0.9]])sc0.changed()sc1.set_color([[1,0,0,0.1],[1,0,0,0.5],[1,0,0,0.9]])sc1.changed()# fig.canvas.draw_idle()  # does not help

mpl_color_bug2

In the above settings, set_color changes both face and edge color together with alpha for individual colors and edge color together with alpha for colormapped scalar too.
But then, thechanged() method reverts face color for colormapped scalars. Face color should not be reverted by callingchanged().

Matplotlib version

  • Operating system: Windows
  • Matplotlib version: 3.0.2
  • Python version: 3.6.7 |Anaconda custom (64-bit)| (default, Dec 10 2018, 20:35:02) [MSC v.1915 64 bit (AMD64)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp