我认为你需要生成子图
请参阅下面的图(我也更改了颜色)
def myplot(matrix1, matrix2):
mymin = np.min(np.array([np.min(matrix1), np.min(matrix2)]))
mymax = np.max(np.array([np.max(matrix1), np.max(matrix2)]))
xsize, ysize = matrix1.shape
x = np.arange(0, ysize, 1)
y = np.arange(0, xsize, 1)
xs, ys = np.meshgrid(x, y)
z1 = matrix1
z2 = matrix2
fig=plt.figure()
ax1 = fig.add_subplot(2, 1, 1, projection='3d')
ax1.plot_surface(xs, ys, z1,color="blue",alpha=0.5,rstride=1, cstride=1)
ax2 = fig.add_subplot(2, 1, 2, projection='3d')
ax2.plot_surface(xs, ys, z2,color="green",alpha=0.5, rstride=1, cstride=1)
plt.tight_layout
plt.show()
mat1 = np.random.random(size = (10, 10))
mat2 = np.random.random(size = (10, 10))
myplot(mat1, mat2)
Edit:利用mymin
and mymax
作为两个 z 轴的限制,使用
ax1.set_zlim(mymin, mymax)
ax2.set_zlim(mymin, mymax)