Adding percentage error plot bar

This commit is contained in:
Aloma Blanch 2020-07-23 12:37:44 -05:00
parent a0040a7090
commit 070428663c

View File

@ -254,6 +254,16 @@ def barPlot(project_folder,DBP,MBP,SBP,PP,Q_avg,save_path):
autolabel(rects1)
autolabel(rects2)
# Create labels
err = []
zip_object = zip(CFD, aimed)
for x1_i, x2_i in zip_object:
err.append(round((x1_i-x2_i)/x2_i*100,2))
# Text on the top of each barplot
for i in range(len(x)):
plt.text(x = x[i]- width/2, y = max(CFD[i],aimed[i])+0.15*max(max(CFD,aimed)), s = str(err[i])+'%', fontsize = 8, color='r')
fig.tight_layout()
# plt.show()
plt.savefig(save_path + '/'+name+'_bar.pdf')