JPablos

Graficar una serie. Simple Python

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