我绘制了两个不同比例的图表,但我无法将它们沿 w 轴组合。需要根据 0 = -pi 的原理将 L(w) 和 -Fi(w) 结合起来。我在 python + matplotlib 中绘图。
import matplotlib.pyplot as plt
import numpy as np
def W(w):
return 36.69487 / (0.00008214*(1j*w)**4 + 0.017538*(1j*w)**3 + 26.440677*(1j*w)**2 + (1j*w))
def A(w):
resW = W(w)
return np.sqrt(resW.real**2 + resW.imag**2)
def L(w):
return 20*np.log10(A(w))
def Fi(w):
resW = W(w)
U, V = resW.real, resW.imag
return np.arctan(V/U)
w = np.linspace(0.01, 1000, 1000)
wzero = np.zeros(w.shape)
fig, ax = plt.subplots()
ax1 = ax.twinx()
ax.plot(w, L(w),color='r')
ax1.plot(w,-Fi(w)-np.pi,color='b')
plt.xscale('log')
plt.xlim([0.01,100])
ax.set_ylabel('L(w)')
ax1.set_ylabel('-Fi(w)')
如果您将坐标原点
ax
放在轴的中间?: