5,100)y=np.linspace(-5,5,100)X,Y=np.meshgrid(x,y)Z=np.sin(np.sqrt(X**2+Y**2))# 创建3D图形fig=plt.figure(figsize=(10,8))ax=fig.add_subplot(111,projection='3d')# 绘制表面surf=ax.plot_surface(X,Y,Z,cmap='viridis')# 添加颜色条fig.colorbar(surf,shrink...
# cmap是颜色映射表 # from matplotlibimportcm # ax.plot_surface(X,Y,Z,rstride=1,cstride=1,cmap=cm.coolwarm)# cmap="rainbow"亦可 # 我的理解的 改变cmap参数可以控制三维曲面的颜色组合,一般我们见到的三维曲面就是 rainbow 的 # 你也可以修改 rainbow 为 coolwarm,验证我的结论 ax.plot_surface(X,Y...
matplotlib是一个用于绘制数据可视化图表的Python库。plot_surface是matplotlib中的一个函数,用于绘制三维曲面图。 plot_surface函数的参数包括X、Y、Z三...
plot_surface(x1, x2, zs, rstride=1, cstride=1, cmap=cm.coolwarm, linewidth=0) plt.show() windows11+powershell PS D:\work\python_work\ModernPython\codes\matplotlib\surface_plot\01> py.exe .\testprj.py 为便于检索,文章收录于: 迦非喵:Matplotlib绘图系列链接整理0 赞同 · 0 评论文章...
plt.figure(1);ax=plt.subplot(111,projection='3d');dx=0.05;dy=0.05;x=np.arange(-1,1+dx,dx);y=np.arange(-1,1+dy,dy);X,Y=np.meshgrid(x,y);Z=(X+Y)*np.exp(-5*(X**2+Y**2))*6.01-0.152;ax.plot_surface(X,Y,Z,cmap=cm.jet);# 设置网格不可见ax.grid(None)# 设置X、Y...
在使用Python的matplotlib库中的plot_surface函数绘图时,cmap参数指的是颜色映射表(colormap)。这个参数用于控制曲面的颜色样式,根据不同的数据值显示不同的颜色。matplotlib支持多种颜色映射表,可以分为几个大类: 连续色彩映射(Sequential colormaps):主要用于表示从低到高的数据范围。比如viridis, plasma, inferno, ma...
fig=plt.figure()ax=fig.add_subplot(111,projection='3d')X=np.arange(-5,5,0.25)Y=np.arange(-5,5,0.25)X,Y=np.meshgrid(X,Y)Z=np.sin(np.sqrt(X**2+Y**2))ax.plot_surface(X,Y,Z,cmap='viridis')plt.show() Python Copy
(x_test, y_test)Ztest = Xtest**-1 + Ytestsurf = ax.plot_surface(Xtest, Ytest, Ztest, cmap=cm.plasma, alpha=1, antialiased=False)fig.colorbar(surf, shrink=0.5, aspect=5)ax.set_ylabel(r'$ Y $', fontsize=16)ax.set_xlabel(r'$ X $', fontsize=16)ax.set_zlabel(r'$ Z...
SurfacePlot ContourPlot FilledContourPlot PolygonPlot BarPlot Text 写在篇后 写在篇前 matplotlib也支持三维作图,但是相对于matlab来讲,感觉功能更弱。当然话说回来,三维作图用的场景相对也更少,所以呢,有一定的知识储备就够了。matplotlib绘制三维图形依赖于mpl_toolkits.mplot3d,用法也比较简单,只需要一个...
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='hot') show() 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 结束篇 Matplotlib 能有今天这样强大的功能和广泛的使用得益于大量的文档和社区开发者。这里提供一些有益的链接。