h lowpass filter with a corner frequency of 100 Hz: >>> import matplotlib.pyplot as plt >>> import numpy as np >>> from scipy import signal ... >>> T = 1e-4 # sampling interval in s >>> f_c, o = 1e2, 5 # corner frequency in Hz (i.e., -3 dB value) and filter order >>> bb, aa = signal.butter(o, f_c, 'lowpass', fs=1/T) ... >>> w, mag, phase = signal.dbode((bb, aa, T)) >>> w /= 2*np.pi # convert unit of frequency into Hertz ... >>> fg, (ax0, ax1) = plt.subplots(2, 1, sharex='all', figsize=(5, 4), ... tight_layout=True) >>> ax0.set_title("Bode Plot of Butterworth Lowpass Filter " + ... rf"($f_c={f_c:g}\,$Hz, order={o})") >>> ax0.set_ylabel(r"Magnitude in dB") >>> ax1.set(ylabel=r"Phase in Degrees", ... xlabel="Frequency $f$ in Hertz", xlim=(w[1], w[-1])) >>> ax0.semilogx(w, mag, 'C0-', label=r"$20\,\log_{10}|G(f)|$") # Magnitude plot >>> ax1.semilogx(w, phase, 'C1-', label=r"$\angle G(f)$") # Phase plot ... >>> for ax_ in (ax0, ax1): ... ax_.axvline(f_c, color='m', alpha=0.25, label=rf"${f_c=:g}\,$Hz") ... ax_.grid(which='both', axis='x') # plot major & minor vertical grid lines ... ax_.grid(which='major', axis='y') ... ax_.legend() >>> plt.show() r‡