import matplotlib.pyplot as plt
# Nuevos datos de potencia en función del diámetro, ahora en kW
diametro = [0.015, 0.03, 0.045, 0.06, 0.075, 0.09]
potencia_electrica = [1723/1000, 1721/1000, 1718/1000, 1715/1000, 1712/1000, 1709/1000] # Convertir a kW
potencia_termica = [5308/1000, 5309/1000, 5311/1000, 5313/1000, 5315/1000, 5317/1000] # 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
ax1.plot(diametro, potencia_electrica, marker='o', color='blue', linestyle='-', linewidth=2, label='Potencia Eléctrica (kW)')
ax1.set_ylabel('Potencia Eléctrica (kW)', fontsize=etiqueta_eje_fontsize)
ax1.tick_params(axis='both', labelsize=etiqueta_ticks_fontsize)
ax1.set_xlabel('Diámetro de la tubería del SRC-PVT (m)', fontsize=etiqueta_eje_fontsize)
ax1.set_ylim(1.705, 1.728) # Ajuste del límite del eje Y izquierdo (kW)
# Crear segundo eje Y para la potencia térmica
ax2 = ax1.twinx()
ax2.plot(diametro, potencia_termica, marker='s', color='red', linestyle='-', linewidth=2, label='Potencia Térmica (kW)')
ax2.set_ylabel('Potencia Térmica (kW)', fontsize=etiqueta_eje_fontsize)
ax2.set_ylim(5.305, 5.325) # Ajuste del límite del eje Y derecho (kW)
# Títulos generales
plt.title('Potencia Eléctrica y Térmica en función del Diámetro (kW)', 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)
# 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)
for spine in ax2.spines.values():
spine.set_edgecolor('black')
spine.set_linewidth(2)
# Ajustar el 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: