import matplotlib.pyplot as plt
# Meses en inglés
months = ['Ene', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']
# Nuevos datos de energía eléctrica y térmica
electric_energy = [238.018, 258.5352, 390.228, 453.18, 449.748, 509.04, 515.158, 418.314, 380.88,
332.7819, 243.75, 177.692]
thermal_energy = [602.64, 677.908, 1032.672, 1211.73, 1233.583, 1404.48, 1424.388, 1152.983, 1041.84,
883.19, 633.6, 448.88]
# Configuración del tamaño de la figura
fig, ax = plt.subplots(figsize=(12, 8))
# Graficar energía eléctrica
ax.plot(months, electric_energy, marker='o', color='blue', linestyle='-', linewidth=2, label='Energía eléctrica')
# Graficar energía térmica
ax.plot(months, thermal_energy, marker='s', color='red', linestyle='-', linewidth=2, label='Energía térmica')
# Configuración de etiquetas y título
ax.set_ylabel('Energía (kWh)', fontsize=20)
ax.set_xlabel('Meses', fontsize=20)
ax.tick_params(axis='both', labelsize=20)
# Título del gráfico
ax.set_title('', fontsize=22)
# Leyenda
ax.legend(loc='upper left', fontsize=20)
# Acentuar el marco del gráfico
for spine in ax.spines.values():
spine.set_edgecolor('black')
spine.set_linewidth(2)
# Ajuste de límites del eje Y
ax.set_ylim(0, 1600)
# Ajuste de diseño
fig.tight_layout()
# Mostrar el gráfico
plt.show()
To embed this program on your website, copy the following code and paste it into your website's HTML: