import matplotlib.pyplot as plt
# Meses en español
months = ['Ene', 'Feb', 'Mar', 'Abr', 'May', 'Jun',
'Jul', 'Ago', 'Sep', 'Oct', 'Nov', 'Dic']
# Nuevos datos de ahorro
savings_city_1 = [1.59, 1.72, 2.57, 2.96, 2.94, 3.31, 3.35, 2.74, 2.50, 2.20, 1.63, 1.20]
savings_city_2 = [3.26, 3.67, 5.61, 6.61, 6.72, 7.67, 7.78, 6.28, 5.67, 4.80, 3.43, 2.42]
# Tamaños de letra personalizables
title_fontsize = 22
axis_label_fontsize = 20
tick_label_fontsize = 20
legend_fontsize = 20
# Crear una figura con un solo eje Y y ajustar el tamaño de la figura
fig, ax = plt.subplots(figsize=(12, 8))
# Graficar ahorro de la ciudad 1
ax.plot(months, savings_city_1, marker='o', color='blue', linestyle='-', linewidth=2, label='Energía Eléctrica')
# Graficar ahorro de la ciudad 2
ax.plot(months, savings_city_2, marker='s', color='red', linestyle='-', linewidth=2, label='Energía Térmica')
# Configuración del eje Y
ax.set_ylabel('Energía (MWh)', fontsize=axis_label_fontsize)
ax.tick_params(axis='both', labelsize=tick_label_fontsize)
# Configuración del eje X
ax.set_xlabel('Meses', fontsize=axis_label_fontsize)
ax.set_xticks(months)
# Ajuste de límites del eje Y
ax.set_ylim(0, max(max(savings_city_1), max(savings_city_2)) + 1)
# Título general con tamaño de letra personalizable
plt.title('', fontsize=title_fontsize)
# Leyenda ubicada dentro del gráfico en la parte superior izquierda con tamaño de letra personalizable
ax.legend(loc='upper left', fontsize=legend_fontsize)
# Eliminar el grid
ax.grid(False)
# Acentuar el marco del gráfico en todos los lados
for spine in ax.spines.values():
spine.set_edgecolor('black')
spine.set_linewidth(2) # Define el grosor del marco
# 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: