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 potencia eléctrica y térmica
electric_power = [0.7678, 0.8394, 1.049, 1.162, 1.116, 1.212, 1.187, 1.038, 1.058, 0.9759, 0.8125, 0.5732]
thermal_power = [1.944, 2.201, 2.776, 3.107, 3.061, 3.344, 3.282, 2.861, 2.894, 2.59, 2.112, 1.448]
# Configuración del tamaño de la figura
fig, ax = plt.subplots(figsize=(12, 8))
# Graficar potencia eléctrica
ax.plot(months, electric_power, marker='o', color='blue', linestyle='-', linewidth=2, label='Potencia eléctrica')
# Graficar potencia térmica
ax.plot(months, thermal_power, marker='s', color='red', linestyle='-', linewidth=2, label='Potencia térmica')
# Configuración de etiquetas y título
ax.set_ylabel('Potencia (kW)', 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.5, 4)
# 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: