Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Description
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
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
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)]