我有一个简单的任务应该有一个简单的解决方案,但我已经尝试了几天.我试着具体一点.
我尝试使用matplotlib的mplot3d和plot_surface绘制曲面.当我绘制数据集"z"的表面并尝试将色彩映射缩放到某个最大值时,我将"vmax"属性更改为此值.这很好用.
当我尝试绘制一个数据集(z)的表面并使用第二个数据集(fc)的面部颜色时,这也可以正常工作.
当我想缩放facecolors的colormap时,facecolors值会否决vmax属性.因此Vmax没有效果(尝试1).线条也消失了,但这是另一个问题.
还试图更改facecolor数据集(fc)的值没有达到预期的效果(attempt2).
我尝试使用缩放的颜色图获得一个图形(如下图'缩放'),但缩放到面部颜色,而不是z值.
下面的代码就是我现在的代码,结果如下所示:

有谁知道我在这里缺少什么?任何想法都表示赞赏!
import pylab as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D
plt.ion()
# creating dataset
profile = np.arange(20)**2
z = profile.repeat(20).reshape(20,20)
fc= np.rot90(z.copy())
x = np.arange(z.shape[0])
y = np.arange(z.shape[1])
X, Y = np.meshgrid(x,y)
# plotting
vmax = 100
fig = plt.figure()
ax = fig.add_subplot(1,4,1, projection='3d', azim=210)
ax.plot_surface(X,Y,z, cmap=plt.cm.jet, cstride=1, rstride=1)
ax.set_title('normal')
ax = fig.add_subplot(1,4,2, projection='3d', azim=210)
ax.plot_surface(X,Y,z, cmap=plt.cm.jet, cstride=1, rstride=1, vmax=vmax)
ax.set_title('scaled')
ax = fig.add_subplot(1,4,3, projection='3d', azim=210)
ax.plot_surface(X,Y,z, facecolors=plt.cm.jet(fc), cstride=1, rstride=1, …Run Code Online (Sandbox Code Playgroud)