From 070428663cedb13862021c23953f038c1d146692 Mon Sep 17 00:00:00 2001 From: Aloma Blanch Date: Thu, 23 Jul 2020 12:37:44 -0500 Subject: [PATCH] Adding percentage error plot bar --- functions.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/functions.py b/functions.py index e71da69..592eb2d 100644 --- a/functions.py +++ b/functions.py @@ -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')