首页 > 其他 > 详细

matplotlib表面三维图

时间:2018-01-26 16:29:48      阅读:273      评论:0      收藏:0      [点我收藏+]

1.basic

2.code

In [88]: from mpl_toolkits.mplot3d import Axes3D

In [89]: from matplotlib import cm

In [108]: from matplotlib.ticker import LinearLocator,FormatStrFormatter

In [91]: import matplotlib.pyplot as plt

In [92]: import numpy as np

In [93]: fig=plt.figure(figsize=(12,9))

In [94]: points=np.arange(-4,4,0.25)

In [95]: xx,yy=np.meshgrid(points,points)

In [96]: r=np.sqrt(xx**2+yy**2)

In [97]: z=np.sin(r)
In [103]: surf=ax.plot_surface(xx,yy,z,rstride=1,cstride=1,cmap=cm.coolwarm,linewidth=0,antialiased=False)

In [104]: ax.set_zlim(-1.01,1.01)
Out[104]: (-1.01, 1.01)

In [105]: ax.zaxis.set_major_locator(LinearLocator(10))

In [109]: ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

In [110]: fig.colorbar(surf,shrink=0.6,aspect=6)
Out[110]: <matplotlib.colorbar.Colorbar at 0xaae3710>

In [111]: plt.show()

3.result

技术分享图片

matplotlib表面三维图

原文:https://www.cnblogs.com/yangjing000/p/8360096.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!