python的matplotlib库学习1

matplotlib是python最著名的绘图库,它提供了一整套和matlab相似的命令API,十分适合交互式地进行制图。而且

也可以方便地将它作为绘图控件,嵌入GUI应用程序中。

今天安装numpy,scipy,matplotlib都安装一天,简直是痛不欲生啊,因此建议用装包利器pip来安装,废话不多说了引用官方文档一个示列看看效果。

from scipy import *
from scipy.special import jn, jn_zeros
import pylab
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
def drumhead_height(n, k, distance, angle, t):
   nth_zero = jn_zeros(n, k)
   return cos(t)*cos(n*angle)*jn(n, distance*nth_zero)
#绘制图形   
theta = r_[0:1:50j]
radius = r_[0:1:50j]
x = array([r*cos(theta) for r in radius])
y = array([r*sin(theta) for r in radius])
z = array([drumhead_height(1, 1, r, theta, 0.5) for r in radius])
#设置坐标轴
fig = pylab.figure()
ax = Axes3D(fig)
ax.plot_surface(x, y, z, rstride=1, cstride=1, cmap=cm.jet)
#设置X,Y,Z轴的标签
ax.set_xlabel("x")
ax.set_ylabel("Y")
ax.set_zlabel("Z")
pylab.show()

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值