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 = [5.07, 5.03, 7.32, 6.06, 7.26, 7.08, 8.13, 5.13, 5.28, 5.16, 6.06, 5.47]
savings_city_2 = [4.82, 5.36, 8.13, 9.50, 9.60, 10.90, 11.05, 8.96, 8.11, 6.95, 5.02, 3.60]

# 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='Cuernavaca')

# Graficar ahorro de la ciudad 2
ax.plot(months, savings_city_2, marker='s', color='red', linestyle='-', linewidth=2, label='Mexicali')

# Configuración del eje Y
ax.set_ylabel('Energy saved (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()

Embed on website

To embed this program on your website, copy the following code and paste it into your website's HTML: