我试着画一个黑体在不同温度下的图,在同一个图中,温度是10,10^3,10^5,10^7,10^9和10^12开尔文。10^12看起来不错,但其他的看起来很平。我已经试着把它放在对数刻度上,但似乎没有帮助
这是我的密码:
import numpy as np
import matplotlib.pylab as plt
k = 1.38 * 10**-23
h = 6.62607015e-34
c = 3e8
def pla(T, nu):
x = (h*nu) / (k*T)
c1 = 2 * h * nu**3
planck = c1 / (np.exp(x) * c**2)
return planck
nus = np.linspace(0, 4e23)
T10 = pla(10, nus)
Te3 = pla(1e3, nus)
Te5 = pla(1e5, nus)
Te7 = pla(1e7, nus)
Te9 = pla(1e9, nus)
Te12 = pla(1e12, nus)
plt.xlabel("frecuencia")
plt.ylabel("temperatura")
plt.plot(nus, T10, color='blue', label='T10')
plt.plot(nus, Te3, color='red', label='Te3')
plt.plot(nus, Te5, color='orange', label='Te5')
plt.plot(nus, Te7, color='purple', label='Te7')
plt.plot(nus, Te9, color='gray', label='Te9')
plt.plot(nus, Te12, color='green', label='Te12')
plt.legend(loc='upper right')
plt.show()
结果:
下面是我在以下位置找到的一个实现:https://stackoverflow.com/a/22417613/6304086
相关问题 更多 >
编程相关推荐