import matplotlib.pyplot as plt
import numpy as np
import pickle

listOfFeatures=[['r1 s1'], ['r1 s4'], ['r1 s5'], ['r1 s1','r1 s4'], ['r1 s1','r1 s5'], ['r1 s4','r1 s5'], ['r1 s1','r1 s4','r1 s5'] ]
featureNames={}
featureNames['r1 s1']='$T_{evap}$'
featureNames['r1 s4']='$T_{cond}$'
featureNames['r1 s5']='$T_{air}$'
featureNames['pa1 apiii']='$P_{elec}$'


def listToString(l):
    r=''
    for i in l:
        r+=str(i)
    return(r.replace(' ',''))

FS=[]
for l in listOfFeatures:
    print(l)
    file = open('FScore_v4_'+listToString(l)+'.pk', 'rb')
    FS.append(pickle.load(file))
    file.close()

plt.rcParams.update({'font.size': 16})
fig, axes = plt.subplots(nrows=2, ncols=2, figsize=(14, 10), dpi=80, facecolor="w", edgecolor="k",sharex=True)
tsToPlot=[4,8,12,16]
for row in range(2):
    for col in range(2):
        ind=row*2+col
        for k in range(len(FS)):
            ar=np.array((FS[k][tsToPlot[ind]]))

            s='['
            for i in range(len(listOfFeatures[k])):
                s+=featureNames[listOfFeatures[k][i]]
                if i < len(listOfFeatures[k])-1:
                    s+=', '
            s+=']'


            axes[row][col].plot(ar[:,0],ar[:,1],label=s,linewidth=3)
#axes.set_xlabel("Threshold factor")
        if col==0:
            axes[row][col].set_ylabel("F1-Score")
        if row==1:
            axes[row][col].set_xlabel("Threshold Factor ($tf$)")
        axes[row][col].grid()
        axes[row][col].set_title('$ns=$'+str(tsToPlot[ind]))
axes[0][0].legend(loc='lower right')
#plt.title(str(features))
plt.show()



