#Importation des bibliothèques
from scipy import signal
import numpy as np     
import matplotlib.pyplot as plt


b, a = signal.cheby1(4, 3, 100, 'low', analog=True, output='ba')

w, h = signal.freqs(b, a, worN=np.logspace(1,5,5000))
GdB=20*np.log10(abs(h))

#Tracé du diagramme de Bode en gain et du gabarit
plt.figure(0)
plt.plot(w, GdB,color='black')
plt.xscale('log')
plt.title('Gabarit à respecter')
plt.xlabel('Fréquence [Hz]')
plt.ylabel('Gain [dB]')
plt.title('Diagramme théorique de Bode pour le gain du système passe-bas de Chebyshev à -1dB / ordre 4')
plt.grid(b=True, which='major',axis="both", color='black', linestyle='-')
plt.grid(b=True, which='minor',axis='both', color='grey', linestyle='--')
plt.fill([.01, 1500, 1500, .01], [-1, -1, -99, -99], '0.9', lw=0) # stop
plt.fill([2000, 2000,   100000,   100000], [ 9, -40, -40,  9], '0.9', lw=0) # pass
plt.axis([10, 100000, -60, 3])
plt.show()