Python超越函数积分运算以及绘图实现代码

yipeiwu_com6年前Python基础

编译环境:ubuntu17.04 Python3.5

所需库:numpy、scipy、matplotlib

下面是理想平面的辐射强度计算(课程大作业~~~)

1、超越函数积分运算

def integral(x,c1,c2,T): 
  return ((c1*0.98)/(x**5))*(1/((np.e**(c2/(x*T)))-1))

resut,err = integrate.quad(integral, 3, 5, args=(c1,c2,T))

2、绘图实现

plt.figure(1) 
ax1 = plt.subplot(211)
plt.sca(ax1) 
plt.plot(fi,functionI(fi,0.5,5,1,e0),label='n=5,ks=0.5')
plt.legend(loc='upper right',bbox_to_anchor = (0.9, 0.9))
plt.xlabel(u'ψ/rad') 
plt.ylabel(u'I/(W/sr)')

ax2 = plt.subplot(212)
plt.sca(ax2) 
plt.plot(fi,functionI(fi,0.5,5,1,e0),label='n=5,ks=0.5')
plt.legend(loc='upper right',bbox_to_anchor = (0.9, 0.9))
plt.xlabel(u'ψ/rad') 
plt.ylabel(u'I/(W/sr)') 

plt.subplots_adjust(wspace=0.5, hspace=0.5) 
plt.show()

说一下plt.subplots_adjust这个函数,这个是用来调整子图之间的间距的啦

成果图:

以上这篇Python超越函数积分运算以及绘图实现代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

django admin.py 外键,反向查询的实例

如下所示: class OrderAdmin(admin.ModelAdmin): list_display = ( '_nick_name', 'time_order'...

Python 按字典dict的键排序,并取出相应的键值放于list中的实例

方法一: def dict_to_numpy_method1(dict): dict_sorted=sorted(dict.iteritems(), key=lambda d:d[...

使用Python写一个量化股票提醒系统

使用Python写一个量化股票提醒系统

大家在没有阅读本文之前先看下python的基本概念, Python是一种解释型、面向对象、动态数据类型的高级程序设计语言。 Python由Guido van Rossum于1989年底...

tensorflow 获取所有variable或tensor的name示例

获取所有variable(每个op中可训练的张量)的name: for variable_name in tf.global_variables(): print(variabl...

python读文件保存到字典,修改字典并写入新文件的实例

实例如下所示: tcode={} transcode={} def GetTcode(): #从文本中获取英文对应的故障码,并保存在tcode字典(故障码文本样例:oxff,0xff...