python(matplotlib5)——Contours 等高线图
生活随笔
收集整理的这篇文章主要介绍了
python(matplotlib5)——Contours 等高线图
小编觉得挺不错的,现在分享给大家,帮大家做个参考.
文章目录
- 前言
- Contours 等高线图
前言
来自 莫烦python的总结。
Contours 等高线图
def f(x,y):return (1-x/2+x**5+y**3)* np.exp(-x**2-y**2)n=256 x=np.linspace(-3,3,n) y=np.linspace(-3,3,n)X,Y = np.meshgrid(x,y) # 至于为什么用这个meshgrid请参考这篇博文:划线的时候,一个X中的元素对应一行Y,https://blog.csdn.net/lllxxq141592654/article/details/81532855#填充颜色 plt.contourf(X,Y,f(X,Y),8,alpha=.75,cmap=plt.cm.hot) # cmap:用哪种形式来呈现等高图,这里是用hot热力图 #添加等高线 C = plt.contour(X,Y,f(X,Y),8,color='black',linewith=5) # 8:8个等高线分了10部分,仔细看图就知道了#给等高线添加注释 plt.clabel(C,inline=True,fontsize=10)总结
以上是生活随笔为你收集整理的python(matplotlib5)——Contours 等高线图的全部内容,希望文章能够帮你解决所遇到的问题。
- 上一篇: python(matplotlib4)—
- 下一篇: python(matplotlib6)—