import matplotlib.pyplot as plt
import numpy as np
# Datos
parametros = ['Longitud de\nla tubería', 'Ancho de\nla cara', 'Diámetro de\nla tubería', 'Flujo másico\ndel HTF']
ef_inicial = [1.212, 1.868, 1.74, 1.542]
ef_final = [2.229, 1.723, 1.522, 1.728]
diferencias_porcentuales = [83.92, 7.76, 12.53, 12.06] # Valores ya en porcentaje
# Posiciones de las barras
x = np.arange(len(parametros)) # Posiciones de las barras
width = 0.35 # Ancho de las barras
# Crear figura y subgráficos
fig, ax = plt.subplots(1, 2, figsize=(20, 8)) # 1 fila, 2 columnas
# Gráfico 1: Potencias iniciales y finales
ax[0].bar(x - width/2, ef_inicial, width, label='Potencia inicial', color='blue', alpha=0.7)
ax[0].bar(x + width/2, ef_final, width, label='Potencia final', color='green', alpha=0.7)
ax[0].set_xticks(x)
ax[0].set_xticklabels(parametros, fontsize=20)
ax[0].set_ylabel('Potencia eléctrica (kW)', fontsize=20)
ax[0].set_title('', fontsize=22)
ax[0].legend(loc='upper left', fontsize=18, frameon=True)
ax[0].grid(axis='y', linestyle='--', alpha=0.7)
ax[0].tick_params(axis='y', labelsize=18)
# Ajustar límites del eje Y para mostrar mejor las barras
ax[0].set_ylim(0, max(max(ef_inicial), max(ef_final)) * 1.2)
# Remarcar los bordes del gráfico 1
for spine in ax[0].spines.values():
spine.set_edgecolor('black')
spine.set_linewidth(2)
# Gráfico 2: Diferencias porcentuales
ax[1].bar(x, diferencias_porcentuales, width, color='orange', alpha=0.7)
ax[1].set_xticks(x)
ax[1].set_xticklabels(parametros, fontsize=20)
ax[1].set_ylabel('\nVariación de la potencia (%)', fontsize=20)
ax[1].set_title('', fontsize=22)
ax[1].grid(axis='y', linestyle='--', alpha=0.7)
ax[1].tick_params(axis='y', labelsize=18)
# Remarcar los bordes del gráfico 2
for spine in ax[1].spines.values():
spine.set_edgecolor('black')
spine.set_linewidth(2)
# Ajustar diseño
plt.tight_layout()
plt.show()
To embed this program on your website, copy the following code and paste it into your website's HTML: