Advertisement
JPablos

Graficar una serie. Simple Python

Mar 10th, 2024 (edited)
522
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. """Graficar una serie dentro de sus límites"""
  2.  
  3. import matplotlib.pyplot as plt
  4.  
  5. # Datos: valores de Hemoglobina Corpuscular Media
  6. serie = [32.70, 32.80, 32.40, 32.10, 32.70, 32.10, 30.60, 33.50, 33.10, 31.90, 32.90]
  7. LIM_INF = 27.0
  8. LIM_SUP = 32.0
  9.  
  10. # Crear un rango de índices para las x
  11. indices = range(1, len(serie) + 1)
  12.  
  13. # Crear el gráfico de línea
  14. plt.plot(indices, serie, label='Serie')
  15.  
  16. # Dibujar líneas horizontales para los límites
  17. plt.axhline(y=LIM_INF, color='r', linestyle='--', label='Límite Inferior')
  18. plt.axhline(y=LIM_SUP, color='g', linestyle='--', label='Límite Superior')
  19.  
  20. # Configurar etiquetas y título
  21. plt.xlabel('Índices')
  22. plt.ylabel('Valores')
  23. plt.title('Gráfico de Hemoglobina Corpuscular Media')
  24. plt.legend()
  25.  
  26. # Mostrar el gráfico
  27. plt.show()
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement