ax = fig.add_subplot(111, projection='3d')x = np.linspace(-5, 5, 100)y = np.linspace(-5, 5, 100)X, Y = np.meshgrid(x, y)Z = np.sin(np.sqrt(X**2 + Y**2))surf = ax.plot_surface(X, Y, Z, cmap='coolwarm')plt.show()A
ax.plot_surface( Xc, Yc, Zc, cstride = 1, rstride = 2, edgecolor = 'y' )#绘图 ax.set_xlabel( 'x' ) ax.set_ylabel( 'y' ) ax.set_zlabel( 'z' ) ax.view_init( 20, 45 ) 1. 2. 3. 4. 5. 6. 7. 8. 9. 上述代码运行结果为: 3、绘制与旋转抛物面具有相同定义域的平面z=...
surf = ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0,...
plot_surface函数接受三个参数:X、Y和Z,分别表示三维数据点的x、y和z坐标值。 下面是plot_surface函数的基本语法: ax.plot_surface(X,Y,Z) 1. 其中,ax是matplotlib库中的一个子模块,用于创建三维图形。X、Y和Z是三维数据点的坐标值,可以是一个二维数组或网格。 plot_surface的风格 plot_surface函数提供了多...
2 给出参数方程:x=10*np.outer(np.cos(u),np.sin(v))y=10*np.outer(np.sin(u),np.sin(v))z=10*np.outer(np.ones(np.size(u)),np.cos(v))3 这是一个球面的参数方程,画出这个球面。ax.plot_surface(x,y,z,cmap='rainbow')4 实际成图。5 ax.plot_surface(x,y,z,cmap=&...
ax1.set_title('3D Surface Plot') ax1.view_init(elev=30, azim=20) # 设置视角 ax1.zaxis.set_major_locator(LinearLocator(10)) ax1.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) # 绘制等高线投影图 contours = ax2.contourf(x, y, z, 20, cmap='viridis') ...
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f')) # Add a color bar which maps values to colors. fig.colorbar(surf, shrink=0.5, aspect=5) plt.show() 六、三角表面图(Tri-Surface plots) 基本用法: 1 ax.plot_trisurf(*args, **kwargs) X,Y,Z:数据 其他参数类似surface-plot cod...
fig = plt.figure() ax = fig.add_subplot(111, projection='3d') ax.plot_surface(X, Y, Z, cmap='rgb') plt.show() 这样就可以得到色彩空间的三维曲面图了。在上述代码中,cmap参数指定了使用的颜色映射,可以根据需要选择不同的颜色映射。
mplot3d import axes3d ax = plt.axes(projection='3d') x = arange(-5, 5, 0.1) y = arange(-5, 5, 0.1)x,y = meshgrid(x, y) R = sqrt(x*2+y**2) z = sin(R) ax.plot_surface(x, y, z) ax.set_xlabel('X Axes') ax.set_ylabel('Y Axes') ax.set_zlabel('Z ...