Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Open
Labels
Description
Summary
importnumpyasnpimportmatplotlib.pyplotaspltfrommatplotlibimportcmfrommatplotlib.colorsimportNormalizeX=np.linspace(0,1,100)Y=np.linspace(0,1,100)X_mesh,Y_mesh=np.meshgrid(X,Y)Z=np.cos((1-X_mesh)*np.pi)*np.cos((1-Y_mesh)*np.pi)*1e+14+1.4e+15Z_colors=np.cos(X_mesh*np.pi)norm=Normalize(vmin=np.min(Z_colors),vmax=np.max(Z_colors))colors=cm.gist_heat_r(norm(Z_colors))[:-1, :-1]fig=plt.figure()ax=fig.add_subplot(111,projection='3d')ax.plot_surface(X_mesh,Y_mesh,Z,facecolors=colors,edgecolor='none')plt.show()
Proposed fix
fig=plt.figure()ax=fig.add_subplot(111,projection='3d')ax.plot_surface(X_mesh,Y_mesh,Z,facecolors=colors,edgecolor='none',shade=False)plt.show()
When colors represent actual data values, shading-induced distortion is critical.
- If
facecolors
is explicitly given,shade=False
should be the default behavior, since the user is already controlling the color manually. - Alternatively, at minimum, this behavior should be clearly documented in the
plot_surface
API page, warning users that shading will distort manually specified facecolors. - Or, provide an explicit warning if both
facecolors
andshade=True
are used together.