import matplotlib.pyplot as plt
# Meses en inglés
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
# Nuevos datos de ahorro
savings_city_1 = [1.63, 1.60, 2.30, 1.90, 2.28, 2.21, 2.56, 1.63, 1.69, 1.64, 1.94, 1.76]
savings_city_2 = [3.48, 3.46, 5.07, 4.20, 5.03, 4.91, 5.62, 3.53, 3.62, 3.55, 4.17, 3.75]
# 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='Electric energy')
# Graficar ahorro de la ciudad 2
ax.plot(months, savings_city_2, marker='s', color='red', linestyle='-', linewidth=2, label='Thermal energy')
# Configuración del eje Y
ax.set_ylabel('Energy (MWh)', fontsize=axis_label_fontsize)
ax.tick_params(axis='both', labelsize=tick_label_fontsize)
# Configuración del eje X
ax.set_xlabel('Months', 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: