frommpl_toolkits.mplot3dimportaxes3dimportmatplotlib.cmascm fig=plt.figure()ax=fig.add_subplot(111,projection='3d')# 创建数据X,Y,Z=axes3d.get_test_data(0.1)# 绘制表面,使用colormap来设置面颜色surf=ax.plot_surface(X,Y,Z,rstride=8,cstride=8,cmap=cm.viridis)# 添加颜色条fig.colorbar(surf...
它使用 matplotlib 的plot_surface函数而不是plot_trisurf。 基本上,您想将 x、y 和 z 变量重塑为相同维度的二维数组。要将第四维添加为颜色图,您必须提供另一个与轴变量具有相同维数的二维数组。 下面是 3d 图的示例代码,其中颜色图对应于 x 值。facecolors参数用于根据您的喜好更改颜色图。请注意,它的值是从...
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, facecolors = my_col, linewidth=0, antialiased=False) ax.set_zlim(-1.01, 1.01) 我不会使用 jet,而是使用一些线性颜色图,例如cubehelix。您可以使用错误的颜色图轻松欺骗眼睛(关于该主题的许多帖子之一)...
# 定义面片颜色 colors = ['red', 'green', 'blue', 'yellow', 'purple', 'orange'] face_colors = [colors[int(i / 25)] for i in range(len(x))] # 将颜色映射到面片上 # 绘制曲面 ax.plot_surface(x, y, z, face_color=face_colors, alpha=0.6) # alpha参数控制透明度 # 设置图形标题...
colors_norm=colors_ref/np.max(colors_ref)#介于(0,1)之间 fig=plt.figure() sub=fig.add_subplot(111,projection='3d')#3d表示三维图像 surf=sub.plot_surface(x_mesh,y_mesh,z_mesh,cmap=plt.cm.Purples,facecolors=plt.cm.Purples(colors_norm))#设置渐变色 ...
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm, linewidth=0, antialiased=False) # Customize the z axis. ax.set_zlim(-1.01, 1.01) ax.zaxis.set_major_locator(LinearLocator(10)) ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) ...
cmap A colormap for the surface patches. facecolors Face colors for the individual patches norm An instance of Normalize to map values to colors vmin Minimum value to map vmax Maximum value to map shade Whether to shade the facecolors In [9]: fig = plt.figure() ...: ax = Axes3D(fig...
surf = ax.plot_surface(x, y, z, rstride=1, cstride=1, facecolors=rgb, linewidth=0, antialiased=False, shade=False) plt.savefig('example4.png',dpi=600, bbox_inches='tight') plt.show() Example 5:三维地形,包含投影(Python)
result = ','.join(colors) 当合并元素比较少的时候,使用join方法看不出太大的效果;但是当元素多的时候,你会发现join的效率还是非常明显的。不过,在使用的时候请注意:join只能用于元素是字符串的list,它不会进行任何的强制类型转换。连接一个存在一个或多个非字符串元素的list时将抛出异常。
C=X*Yax=plt.axes(projection='3d')ax.plot_surface(X,Y,Z,rstride=1,cstride=1,facecolors=cm.coolwarm(C),shade=False)plt.show()