def surface_plot(figure,X,Y,Z,color1,color2=None,xlabel="",ylabel="",zlabel="",alpha=1.0,linewidth=3,label=""):
from mpl_toolkits.mplot3d import axes3d
from matplotlib.colors import LinearSegmentedColormap
if color2 is None:
color2 = color1
cdict = {'red': ((0.0, color1[0], color1[0]),(1.0, color2[0], color2[0])),
'green': ((0.0, color1[1], color1[1]),(1.0, color2[1], color2[1])),
'blue': ((0.0, color1[2], color1[2]),(1.0, color2[2], color2[2]))}
cmap = LinearSegmentedColormap('CMap', cdict)
font = fm.FontProperties(family = 'Trebuchet', weight ='light')
figure.patch.set_facecolor('white')
axes = figure.add_subplot(111,projection='3d')
if X.ndim<2:
X = np.tile(np.array(X),(Y.shape[-1],1)).transpose()
if Y.ndim<2:
Y = np.tile(np.array(Y),(X.shape[0],1))
axes.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap=cmap,alpha=alpha,linewidth=linewidth,label=label)
axes.set_xlabel(xlabel,fontproperties=font, size=10, style='italic')
axes.set_xlim(X.min(),X.max())
axes.set_xticklabels(axes.get_xticks(),fontproperties=font, size=12)
axes.set_ylabel(ylabel, fontproperties=font, size=10, style='italic')
axes.set_ylim(Y.min(),Y.max())
axes.set_yticklabels(axes.get_yticks(),fontproperties=font, size=12)
axes.set_zlabel(zlabel, fontproperties=font, size=10, style='italic')
axes.set_zlim(Z.min(),Z.max())
axes.set_zticklabels(axes.get_zticks(),fontproperties=font, size=12)
评论列表
文章目录