在matplotlib中Matlab的surf(x,y,z,c)的等价物是什么?

bow*_*ang 8 python matlab matplotlib

我想实现的功能等surf(x,y,z,c)在MATLAB中,在这里x,y并且z是坐标,c是一个变量的值,我可以使用c来定义颜色.我不知道如何实现它matplotlib.

Dan*_*Dan 6

我已经使用类似以下的代码完成了此操作(指定了facecolors时,请参见边缘线在mplot3d surf中消失):

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
import matplotlib.pyplot as plt
import matplotlib
from pylab import *
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')


#Create X and Y data
x = np.arange(xmin, xmax, xstep)
y = np.arange(ymin, ymax, ystep)
X, Y = np.meshgrid(x, y)


surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors=C, antialiased=True)

#Show the plot
plt.show()
Run Code Online (Sandbox Code Playgroud)