You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
scatter - set_facecolors is not working on Axes3D #9725
importnumpyasnpimportmatplotlib.pyplotaspltimportmatplotlibimportmatplotlib.cmascmxfrommpl_toolkits.mplot3dimportAxes3Dplt.figure()
jet=cm=plt.get_cmap('jet')
cNorm=matplotlib.colors.Normalize(vmin=1, vmax=10)
scalarMap=cmx.ScalarMappable(norm=cNorm, cmap=jet)
cells=10ax=plt.subplot(1,1,1, projection='3d')
pos=np.random.uniform(0, 1, (10, 3))
scat=ax.scatter(pos[:,0],pos[:,1],pos[:,2],
edgecolors=None,
facecolors= [scalarMap.to_rgba(1) forcondinrange(10)])
scat.set_facecolors([scalarMap.to_rgba(10) forcondinrange(10)])
plt.show()
##the dots should be red, but they are blue
This is still an issue. Prior to finding this bug report I posted my own examples as a new bug report because the examples I found were all related to animation just like the context given here. Animation is not the cause.
But, as pointed out in those examples, I believe the issue should be handled together with the issue of coexisting collection-level alpha value and alpha values coming from RGBA colors.
Ran into this issue when updating color limits with scat.clim(), the displayed image from plt.show() is correct, but saved image with plt.savefig() shows wrong (different) facecolor and edgecolor. Using the suggested workaround set_3d_properties() works for now.
@tacaswell I tried more cases, and find that my case could be related to plt.colorbar(), but I'm not 100% sure. This MWE is adapted from above. They look the same on screen but different as files.
Activity
[-]scatter, set_facecolors is not working on Axes3D[/-][+]scatter - set_facecolors is not working on Axes3D[/+]afvincent commentedon Nov 9, 2017
@orena1 Thank you for the report :).
I can confirm that the dots were already blue since at least Matplotlib 1.5.3. (they probably never turned red...)
Here is a smaller MWE, with a possible workaround for the moment (though I am not 100% sure why it works):
Attn @WeatherGod
tacaswell commentedon Nov 13, 2017
Moved to 2.2 as this is not a regression.
stippingerm commentedon Jan 8, 2019
This is still an issue. Prior to finding this bug report I posted my own examples as a new bug report because the examples I found were all related to animation just like the context given here. Animation is not the cause.
But, as pointed out in those examples, I believe the issue should be handled together with the issue of coexisting collection-level alpha value and alpha values coming from RGBA colors.
liuzhenqi77 commentedon Jul 5, 2020
Ran into this issue when updating color limits with
scat.clim(), the displayed image fromplt.show()is correct, but saved image withplt.savefig()shows wrong (different) facecolor and edgecolor. Using the suggested workaroundset_3d_properties()works for now.Matplotlib version: Ubuntu 16.04, 3.3.0rc1+149.g8c2fbda, Qt5Agg backend, Python 3.7.6
tacaswell commentedon Jul 5, 2020
@liuzhenqi77 Do you have a mininal example where it looks right on the screen but saving it comes out wrong?
liuzhenqi77 commentedon Jul 5, 2020
@tacaswell I tried more cases, and find that my case could be related to
plt.colorbar(), but I'm not 100% sure. This MWE is adapted from above. They look the same on screen but different as files.My original user case was,
When setting color with
c=, there could be two ways to adjust the color limit:vmaxandvmin, this works forshowbut not forsavefigscat.clim(), this is not working for both cases, although the colorbar changes.