import sys, datetime, copy, os from dateutil.relativedelta import relativedelta import numpy as np; np.set_printoptions(threshold=sys.maxsize) import matplotlib; matplotlib.use('Agg') import matplotlib.pyplot as plt import matplotlib.colors as clr from mpl_toolkits.basemap import Basemap import seaborn as sns from matplotlib.colors import ListedColormap from netCDF4 import Dataset nc = Dataset('/work/users/hmo/remoclic/Phuong/PHD/BC_2023/Tan/NC/Del_Geo.nc') Model = nc.variables['model'][:] Time = nc.variables['time'][:] aph = nc.variables['aph'][:] org = nc.variables['org'][:] qm = nc.variables['qm'][:] #xlabels = ['R1','R2','R3','R4','R5','R6','R7'] #title = ["Num of FD event","Mean Duration (day)","Mean Severity (%)","Onset Mean Decline Speed (%/pentad)","Rate of Depletion (%)","Intensity (%/day)"] xlabels = ["CNRM","CSIRO","ECEA","GFDL","HadG","MPI","ENS","ENS1"] #title = ["DJF","MAM","JJA","SON"] #Amax = [ 7, 150, 4000, 85, 35, 35 ] Amax = [ 1000, 1000, 1000, 1000 ] Xlab=[] Del1=[] Del2=[] Del3=[] for i in range(0,len(xlabels)): del1=1 + i*3 del2=2 + i*3 del3=3 + i*3 xlab=i+1 Del1.append(del1) Del2.append(del2) Del3.append(del3) Xlab.append(xlab) #nbox = len(Season) #fig, ax = plt.subplots(nbox,figsize=(6,10),sharey=False) #fig, ax = plt.subplots(nbox,figsize=(8,10),sharey=False) fig, ax = plt.subplots(figsize=(10, 6)) plt.subplots_adjust(hspace=0.4) plt.subplots_adjust(top=1) #plt.subplots_adjust(left=0.01) #plt.subplots_adjust(right=0.02) c1 = "red" c2 = "blue" c3 = "green" #for k in range(len(Season)): data1 = (r_org[:,k,:]) data2 = (r_qm[:,k,:]) # ymax = round(np.nanmax(data)); ymin = round(np.nanmin(data)) ymax = Amax[k]; ymin = 0 yticks = np.linspace(ymin,ymax,5) # ax[k].boxplot(data1, sym='k+') ax[k].boxplot(data1, positions = Del1, notch = True, vert = True, patch_artist = True, # labels = list_of_files, # labels = Del1, ## labels = Xlab, boxprops=dict(facecolor=c1, color=c1)) ax[k].boxplot(data2, positions = Del2, notch = True, vert = True, patch_artist = True, # labels = list_of_files, ## labels = Xlab, boxprops=dict(facecolor=c2, color=c2)) # ax[k].set_title('var'+str(k+1)) ax[k].set_title(title[k]) # ax[k].set_xticklabels(xlabels) ax[k].set_yticks(yticks) #plt.show() fig.savefig('box_model_new_test.pdf', bbox_inches="tight", pad_inches=.05, dpi=600)