Advertisement
Stex6299

Untitled

Nov 23rd, 2020
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. #%% Due plot uno sopra l'altro [subplots]
  2.  
  3. # Ritorna un oggetto figura e un array di assi, uno per ogni plot
  4. fig, axs = plt.subplots(2, 1, sharex=True)
  5.  
  6. # Remove horizontal space between axes
  7. fig.subplots_adjust(hspace=0)
  8.  
  9. # Imposto la dimensione
  10. fig.set_size_inches(12,5)
  11. fig.suptitle("Titolo", fontsize=16)
  12.  
  13. # Mostro la griglia
  14. axs[0].grid()
  15. axs[1].grid()
  16.  
  17. # Imposto asse x e y (Nota: x รจ condiviso)
  18. axs[0].set_xlabel("Frequenza (Hz)",fontsize=14)
  19. axs[0].set_ylabel("Ampiezza (V)",fontsize=14)
  20.  
  21. # Plotto dei dati
  22. axs[0].plot(time,v1, label='Generatore', color='y')
  23. axs[0].plot(time,v2, label='Segnale filtrato', color='b')
  24.  
  25. # Mostro la legenda
  26. axs[0].legend(fontsize=14) # <--- note the default location "best"
  27.  
  28. # Va dato sempre per mostrare tutte le figure esistenti
  29. plt.show()
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement