改进子批的大小和空间

2024-10-02 20:42:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着调整横向磁场和电场波的4个子带之间的透射和反射间距。我把这4幅图加在一幅图上。我的目标是改变子地块的边距,这样我就不会得到重叠的子地块。我用了下面的代码

import matplotlib.pyplot as plt
import numpy as np


"DEFINE FRESNEL EQUATIONS"


"""Define reflection coefficient for Transverse electric waves"""

### Reflection coefficient

def Ref_1(theta):

    n_1=1.33

    r_TE_1 = np.cos(theta) - np.sqrt(n_1**2 - np.sin(theta)**2)
    r_TE_1 = r_TE_1 / (r_TE_1 + 2*np.sqrt(n_1**2 - np.sin(theta)**2))

    return r_TE_1


###  transmission coefficient

def Trans_1(theta):

    n_2=1.5

    r_TE_2 = 2*np.cos(theta)
    r_TE_2 = r_TE_2 / (np.cos(theta) + np.sqrt(n_2**2 - np.sin(theta)**2))

    return r_TE_2


"""Define reflection coefficient for Transverse magnetic waves"""


### Reflection coefficient

def Ref_2(theta):

    n_1=1.33

    r_TM = np.sqrt(n_1**2 - np.sin(theta)**2) - n_1**2*np.cos(theta)
    r_TM = r_TM / (np.sqrt(n_1**2 - np.sin(theta)**2) + n_1**2*np.cos(theta))

    return r_TM


###  transmission coefficient

def Trans_2(theta):

    n_2=1.5

    r_TM_2 = 2*np.cos(theta)
    r_TM_2 = r_TM_2 / (np.cos(theta)*n_2**2+np.sqrt(n_2**2-np.sqrt(theta))**2)

    return r_TM_2


"Set Fontlabel, Fontaxis"
Fontlabel=12
Fontaxis=13

"Plot results"
plt.figure()
fig=plt.figure()

Hoek = np.linspace(0,90,1)
print(Trans_2(100*(180/np.pi)))
ax1=fig.add_subplot(221)
ax1.plot(Hoek,Ref_1(Hoek),'blue',linewidth=0.8)
plt.title('TE gepolariseerd licht bij Refrectie')
plt.xlabel('$Hoek (\Theta)$')
plt.ylabel('$Amplitude$')

ax2=fig.add_subplot(222)
ax2.plot(Hoek,Trans_1(Hoek),'red',linewidth=0.8)
plt.title('TE gepolariseerd licht bij Transmissie')
plt.xlabel('$Hoek (\Theta)$')
plt.ylabel('$Amplitude$')

ax3=fig.add_subplot(223)
ax3.plot(Hoek,Ref_2(Hoek),'green',linewidth=0.8)
plt.title('TM gepolariseerd licht bij Reflectie')
plt.xlabel('$Hoek (\Theta)$')
plt.ylabel('$Amplitude$')


ax4=fig.add_subplot(224)
ax4.plot(Hoek,Trans_2(Hoek),'black',linewidth=0.8)
plt.title('TM gepolariseerd licht bij Transmissie')
plt.xlabel('$Hoek (\Theta)$')
plt.ylabel('$Amplitude$')
plt.subplots_adjust(hspace=0.9)
#plt.show()

有了这个子图,我得到了以下糟糕的格式。我不知道如何更改子图边距,这样就不会得到相互重叠的子图

enter image description here


Tags: reftransreturndefnpfigpltsqrt