1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
| def graphe(nomPorteur, nomCapteur, triVitesse, triFinal, Freq, save, affichage):
graphique = plt.figure (figsize=(9, 5))
# Choix d'une abscisse (nombre de canal) différente en fonction du capteur
if nomCapteur in ["EM2040c", "Em2040c", "em2040c", "EM2040p", "Em2040p", "em2040p"]:
Abscisse = np.linspace (1, 96, 96)
elif nomCapteur in ["EM710", "Em710", "em710", "EM122", "Em122", "em122", "EM1002", "Em1002", "em1002",
"EM302", "Em302", "em302", "EM712", "Em712", "em712"]:
Abscisse = np.linspace (1, 128, 128)
elif nomCapteur in ["EM3002", "Em3002", "em3002"]:
Abscisse = np.linspace (1, 80, 80)
# Palette de couleur restreignant le nombre de fichier à 8
couleur = ["blue", "cyan", "green", "brown", "yellow", "orange", "red", "black"]
# Création des graphiques
for d in range (0, len (triFinal[0])):
plt.plot(Abscisse, triFinal[:, d], color=couleur[d], linewidth=1.5,
label=str (int (triVitesse[d])) + ' Nds')
if nomCapteur in ["EM2040c", "Em2040c", "em2040c", "EM2040p", "Em2040p", "em2040p"]:
plt.xlim (0, 97)
plt.xticks (np.linspace (0, 95, 20, endpoint=True))
elif nomCapteur in ["EM710", "Em710", "em710", "EM122", "Em122", "em122", "EM1002", "Em1002",
"em1002", "EM302", "Em302", "em302", "EM712", "Em712", "em712"]:
plt.xlim (0, 130)
elif nomCapteur in ["EM3002", "Em3002", "em3002"]:
plt.xlim (0, 82)
# les lignes suivantes permettent de gérer les légendes, titres et sauvegardes des graphiques
plt.legend (loc='upper right', fontsize='x-small', fancybox=0, shadow=1, bbox_to_anchor=(1.13, 0.7))
plt.xlabel ('Numero du canal')
plt.ylabel ('Niveau en dB')
plt.title ('Mesure de bruit (dB) en fonction de la vitesse du navire (Nds) \n (' +
nomPorteur + ' - ' + nomCapteur + ' - Frequence ' + str (Freq) + ' kHz)')
plt.grid (color='pink', linestyle='-', axis='y')
if save == True:
plt.savefig ('Niveau_bruit_' + str (nomPorteur) + '_' + nomCapteur + '_' + str (Freq) + '_kHz',
dpi=500, orientation='landscape')
if affichage == True:
plt.show (block=graphique)
else:
plt.close (graphique) |
Partager