import matplotlib.pyplot as plt

# Nuevos datos de potencia en función de la longitud
longitud = [7, 8, 9, 10, 11, 12, 13]
potencia_electrica = [2438, 2420, 2404, 2389, 2375, 2363, 2351]  # En W
potencia_termica = [5560, 5618, 5674, 5729, 5782, 5834, 5885]    # En W

# Convertir potencia a kilovatios
potencia_electrica_kW = [p / 1000 for p in potencia_electrica]  # Convertir a kW
potencia_termica_kW = [p / 1000 for p in potencia_termica]      # Convertir a kW

# Tamaños de letra personalizables
titulo_fontsize = 22
etiqueta_eje_fontsize = 20
etiqueta_ticks_fontsize = 20
leyenda_fontsize = 20

# Crear una figura y ejes
fig, ax1 = plt.subplots(figsize=(12, 8))

# Graficar potencia eléctrica en kW
ax1.plot(longitud, potencia_electrica_kW, marker='o', color='blue', linestyle='-', linewidth=2, label='Potencia Eléctrica')
ax1.set_ylabel('Potencia Eléctrica (kW)', fontsize=etiqueta_eje_fontsize)
ax1.tick_params(axis='both', labelsize=etiqueta_ticks_fontsize)
ax1.set_xlabel('Longitud de la tubería del SRC-PVT (m)', fontsize=etiqueta_eje_fontsize)
ax1.set_ylim(2.3, 2.5)  # Ajuste del límite del eje Y izquierdo en kW

# Crear segundo eje Y para la potencia térmica en kW
ax2 = ax1.twinx()
ax2.plot(longitud, potencia_termica_kW, marker='s', color='red', linestyle='-', linewidth=2, label='Potencia Térmica')
ax2.set_ylabel('Potencia Térmica (kW)', fontsize=etiqueta_eje_fontsize)
ax2.set_ylim(5.5, 5.9)  # Ajuste del límite del eje Y derecho en kW

# Títulos generales
plt.title('', fontsize=titulo_fontsize)

# Integrar leyendas en un solo cuadro a la izquierda
lines1, labels1 = ax1.get_legend_handles_labels()
lines2, labels2 = ax2.get_legend_handles_labels()
ax1.legend(lines1 + lines2, labels1 + labels2, loc='upper left', fontsize=leyenda_fontsize, frameon=True)

# Ajustar el tamaño de la numeración del eje Y derecho
ax2.tick_params(axis='y', labelsize=20)  # Tamaño de las etiquetas del eje Y derecho

# Eliminar el grid
ax1.grid(False)

# Acentuar el marco del gráfico en todos los lados
for spine in ax1.spines.values():
    spine.set_edgecolor('black')
    spine.set_linewidth(2)  # Define el grosor del marco

for spine in ax2.spines.values():
    spine.set_edgecolor('black')
    spine.set_linewidth(2)  # Define el grosor del marco

# Ajustar el 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: