import numpy as np
from scipy import signal as signal
import matplotlib.pyplot as plt
norder = 1
hpf = signal.butter(norder, 1.0, btype='high', analog=True) # For the filter, cutoff frequency is normalized to 1
wc = 80.0 # Actual required filter cutoff frequency
w = np.logspace(np.log10(10.0), np.log10(100000), 200) / wc
w, h = signal.freqs(*hpf, worN=w)
ymin, ymax, ystep = (-5.0, 5.0, 1.0)
fig, ax = plt.subplots(figsize=(8, 6))
ax.semilogx(wc*w, 20 * np.log10(abs(h)), '-', markersize=2, markeredgecolor='k')
ax.set_title('Butterworth order {:d} HPF frequency response'.format(norder))
ax.set_xlabel('Frequency, Hz')
ax.set_ylabel('Amplitude, dB')
ax.set_yticks(np.linspace(ymin, ymax, int((ymax-ymin)/ystep)+1))
ax.set_ylim(ymin, ymax)
ax.margins(0, 0.1)
ax.grid(which='both', axis='both')
ax.axvline(wc, color='green', lw=1, ls='--')
ax.axhline(0, color='k', lw=1)
fig.savefig('hpf_fr.png')
plt.show()