import matplotlib.pyplot as plt import numpy as np import os from data_utils import computing_confidence_intervals,data_mean,bootstrapping_CI os.chdir(f'/home/vsansi01/ACC_R_values/') print(os.getcwd()) xx_ticks = [] variables = ("2020","2021","2020-2021") files_S2S = ['ACC_S2S_2020_t2m_week3.npy','ACC_S2S_2021_t2m_week3.npy','ACC_S2S_t2m_week3.npy'] files_GraphOP = ['ACC_GraphOP_2020_t2m_week3.npy','ACC_GraphOP_2021_t2m_week3.npy','ACC_GraphOP_t2m_week3.npy'] files_GraphFT = ['ACC_GraphFT_2020_t2m_week3.npy','ACC_GraphFT_2021_t2m_week3.npy','ACC_GraphFT_t2m_week3.npy'] acc_values_3weeks_2020_2021 = { 'S2S': data_mean(files_S2S), 'GraphOP': data_mean(files_GraphOP), 'GraphFT': data_mean(files_GraphFT) } error_bar_week = { 'S2S': bootstrapping_CI(files_S2S), 'GraphOP': bootstrapping_CI(files_GraphOP), 'GraphFT': bootstrapping_CI(files_GraphFT) } x = np.arange(len(variables)) # the label locations width = 0.2 # the width of the bars multiplier = 0 colors = plt.cm.get_cmap('tab10') # Using a color-blind-friendly colormap colors = colors(3) fig, ax = plt.subplots(layout='constrained') for (attribute, measurement), (att,errors) in zip(acc_values_3weeks_2020_2021.items(),error_bar_week.items()): offset = width * multiplier #if attribute == 'S2S': # rect = ax.bar(x + offset, acc_values_week2_ensemble_mean, width, label='S2S ensemble mean', alpha=0.2, color = 'b') plt.errorbar(x + offset,measurement, yerr=errors, ecolor='k',fmt = 'None', capsize=3, capthick=0.5) if attribute == 'GraphFT': rects = ax.bar(x + offset, measurement, width, label=attribute,color=colors) else: rects = ax.bar(x + offset, measurement, width, label=attribute) #rects1 = ax.bar(x + offset, ) #ax.bar_label(rects, padding=5) multiplier += 1 # Add some text for labels, title and custom x-axis tick labels, etc. ax.set_ylabel('ACC') ax.set_xlabel('Data test') #ax.set_title('Variables') ax.set_xticks(x + width, variables) ax.legend(loc='upper right') ax.set_ylim(0, 0.7) plt.savefig('/home/vsansi01/Barplot_acc_2020-2021.jpeg',dpi=300)