def REE(self, Left=0, Right=16, X0=1, X1=15, X_Gap=15, Base=-1,
            Top=6, Y0=-1,
            Y1=3, Y_Gap=5, FontSize=12,
            xLabel=r'$REE-Standardlized-Pattern$', yLabel='', width=12, height=12, dpi=300):

        self.axes.clear()
        self.axes.spines['right'].set_color('none')
        self.axes.spines['top'].set_color('none')
        self.WholeData = []
        self.OutPutData = pd.DataFrame()
        self.LabelList=[]
        self.algebraDeltaEuList=[]
        self.geometricDeltaEuList=[]
        self.LaPrDeltaCeList=[]
        self.LaNdDeltaCeList=[]
        self.LaSmList=[]
        self.LaYbList=[]
        self.GdYbList=[]
        self.LREEList=[]
        self.MREEList=[]
        self.HREEList=[]
        self.ALLREEList=[]
        self.BinHREEList=[]
        self.BinLREEList=[]
        self.L_HREEList=[]

        self.AllAlpha=[]
        self.AllWidth = []
        self.AllSize = []

        #raw = self._df


        raw = self.CleanDataFile(self._df)

        self.FontSize = FontSize

        PointLabels = []
        k = 0


        slider_value=int(self.standard_slider.value())

        item_value=int(self.item_slider.value())




        if slider_value < len(self.StandardsName):
            standardnamechosen = self.StandardsName[slider_value]
            standardchosen = self.Standards[standardnamechosen]
            self.textbox.setText(self.reference+"\nStandard Chosen: "+self.StandardsName[slider_value])

            right_label_text=self.StandardsName[slider_value]

        elif len(self._given_Standard)<=0:
            standardnamechosen = self.StandardsName[slider_value-1]
            standardchosen = self.Standards[standardnamechosen]
            self.textbox.setText(self.reference+"\nStandard Chosen: "+self.StandardsName[slider_value-1])

            right_label_text = self.StandardsName[slider_value-1]

        else:
            standardchosen = self._given_Standard
            self.textbox.setText(self.reference + "\n You are using Self Defined Standard")
            right_label_text = "Self Defined Standard"

        for i in range(len(raw)):
            # raw.at[i, 'DataType'] == 'User' or raw.at[i, 'DataType'] == 'user' or raw.at[i, 'DataType'] == 'USER'

            TmpLabel = ''
            LinesX = []
            LinesY = []
            TmpEu = raw.at[i, 'Eu'] / standardchosen['Eu']
            TmpSm = raw.at[i, 'Sm'] / standardchosen['Sm']
            TmpGd = raw.at[i, 'Gd'] / standardchosen['Gd']
            TmpCe = raw.at[i, 'Ce'] / standardchosen['Ce']
            TmpLa = raw.at[i, 'La'] / standardchosen['La']
            TmpPr = raw.at[i, 'Pr'] / standardchosen['Pr']
            TmpNd = raw.at[i, 'Nd'] / standardchosen['Nd']
            TmpYb = raw.at[i, 'Yb'] / standardchosen['Yb']

            algebraEu = 2*TmpEu/(TmpSm+TmpGd)
            geometricEu = TmpEu/np.power((TmpSm*TmpGd),0.5)

            firstCe=2*TmpCe/(TmpLa+TmpPr)
            secondCe=3*TmpCe/(2*TmpLa+TmpNd)

            LaYb=TmpLa/TmpYb
            LaSm=TmpLa/TmpSm
            GdYb=TmpGd/TmpYb


            tmpLREEResult = 0
            tmpMREEResult = 0
            tmpHREEResult = 0
            tmpWholeResult = 0
            tmpBinLREE=0
            tmpBinHREE=0

            for j in self.Element:

                if j in self.LREE:
                    tmpLREEResult += raw.at[i, j]
                elif j in self.MREE:
                    tmpMREEResult += raw.at[i, j]
                elif j in self.HREE:
                    tmpHREEResult += raw.at[i, j]

                if j in self.BinLREE:
                    tmpBinLREE += raw.at[i, j]
                elif j in self.BinHREE:
                    tmpBinHREE += raw.at[i, j]

                tmpWholeResult+= raw.at[i, j]



            self.LabelList.append(raw.at[i, 'Label'])
            self.algebraDeltaEuList.append( algebraEu )
            self.geometricDeltaEuList.append( geometricEu )
            self.LaPrDeltaCeList.append(firstCe)
            self.LaNdDeltaCeList.append(secondCe)
            self.LaSmList.append(LaSm)
            self.LaYbList.append(LaYb)
            self.GdYbList.append(GdYb)
            self.LREEList.append( tmpLREEResult )
            self.MREEList.append( tmpMREEResult )
            self.HREEList.append( tmpHREEResult )
            self.ALLREEList.append( tmpWholeResult )
            self.BinHREEList.append(tmpBinHREE)
            self.BinLREEList.append(tmpBinLREE)
            self.L_HREEList.append(tmpBinLREE/tmpBinHREE)

            '''
            for i in self.data_to_norm.columns.values.tolist():
                if i not in self.Element:
                    self.data_to_norm = self.data_to_norm.drop(i, 1)            
            '''

            Y_bottom=0
            Y_top=0

            for j in range(len(self.Element)):
                tmp = raw.at[i, self.Element[j]] / standardchosen[self.Element[j]]
                self.data_to_norm.at[i, self.Element[j]] = tmp
                tmpflag = 1
                a = 0
                try:
                    a = math.log(tmp, 10)
                except(ValueError):
                    tmpflag = 0
                    pass
                if (tmpflag == 1):
                    if Y_bottom >a:Y_bottom =a
                    if Y_top<a:Y_top=a

            self.axes.set_ylim(Y_bottom, Y_top+1)

            if item_value == 0:
                self.item_left_label.setText('Show All')
                for j in range(len(self.Element)):
                    tmp = raw.at[i, self.Element[j]] / standardchosen[self.Element[j]]
                    self.data_to_norm.at[i, self.Element[j]] = tmp
                    tmpflag = 1
                    a = 0
                    try:
                        a = math.log(tmp, 10)
                    except(ValueError):
                        tmpflag = 0
                        pass
                    if (tmpflag == 1):
                        if (raw.at[i, 'Label'] in PointLabels or raw.at[i, 'Label'] == ''):
                            self.WholeData.append(math.log(tmp, 10))
                            TmpLabel = ''
                        else:
                            PointLabels.append(raw.at[i, 'Label'])
                            TmpLabel = raw.at[i, 'Label']

                        LinesY.append(a)
                        LinesX.append(j + 1)
                        self.axes.scatter(j + 1, math.log(tmp, 10), marker=raw.at[i, 'Marker'],
                                          s=raw.at[i, 'Size'], color=raw.at[i, 'Color'], alpha=raw.at[i, 'Alpha'],
                                          label=TmpLabel)
                self.axes.plot(LinesX, LinesY, color=raw.at[i, 'Color'], linewidth=raw.at[i, 'Width'],
                               linestyle=raw.at[i, 'Style'], alpha=raw.at[i, 'Alpha'])

                if (self.show_data_index_cb.isChecked()):

                    if 'Index' in self._df_back.columns.values:
                        self.axes.annotate(self._df_back.at[i, 'Index'],
                                           xy=(LinesX[-1], LinesY[-1]),
                                           color=self._df.at[i, 'Color'],
                                           alpha=self._df.at[i, 'Alpha'])
                    else:
                        self.axes.annotate('No' + str(i + 1),
                                           xy=(LinesX[-1],
                                               LinesY[-1]),
                                           color=self._df.at[i, 'Color'],
                                           alpha=self._df.at[i, 'Alpha'])





            else:
                self.item_left_label.setText(self.AllLabel[item_value-1])

                for j in range(len(self.Element)):
                    tmp = raw.at[i, self.Element[j]] / standardchosen[self.Element[j]]
                    self.data_to_norm.at[i, self.Element[j]] = tmp
                    tmpflag = 1
                    a = 0
                    try:
                        a = math.log(tmp, 10)
                    except(ValueError):
                        tmpflag = 0
                        pass
                    if (tmpflag == 1):
                        if (raw.at[i, 'Label'] in PointLabels or raw.at[i, 'Label'] == ''):
                            TmpLabel = ''
                        else:
                            PointLabels.append(raw.at[i, 'Label'])
                            TmpLabel = raw.at[i, 'Label']
                        alpha= raw.at[i, 'Alpha']
                        linewidth= raw.at[i, 'Width']
                        pointsize= raw.at[i, 'Size']

                        if raw.at[i, 'Label'] == self.AllLabel[item_value - 1]:
                            LinesY.append(a)
                            LinesX.append(j + 1)
                            self.WholeData.append(math.log(tmp, 10))
                            self.axes.scatter(j + 1, math.log(tmp, 10), marker=raw.at[i, 'Marker'],
                                              s=pointsize, color=raw.at[i, 'Color'], alpha=alpha,
                                              label=TmpLabel)
                        self.axes.plot(LinesX, LinesY, color=raw.at[i, 'Color'], linewidth=linewidth,linestyle=raw.at[i, 'Style'], alpha=alpha)

                print(LinesX,LinesY)

                if (self.show_data_index_cb.isChecked()):

                    if len(LinesX) > 0 and len(LinesY) > 0:
                        if 'Index' in self._df_back.columns.values:
                            self.axes.annotate(self._df_back.at[i, 'Index'],
                                               xy=(LinesX[-1], LinesY[-1]),
                                               color=self._df.at[i, 'Color'],
                                               alpha=self._df.at[i, 'Alpha'])
                        else:
                            self.axes.annotate('No' + str(i + 1),
                                               xy=(LinesX[-1], LinesY[-1]),
                                               color=self._df.at[i, 'Color'],
                                               alpha=self._df.at[i, 'Alpha'])


        Tale = 0
        Head = 0

        if (len(self.WholeData) > 0):
            Tale = min(self.WholeData)
            Head = max(self.WholeData)+0.5

        Location = round(Tale - (Head - Tale) / 5)

        count = round((Head - Tale) / 5 * 7) + 1



        if (self.legend_cb.isChecked()):
            self.axes.legend(bbox_to_anchor=(1.05, 1), loc=2, borderaxespad=0, prop=fontprop)




        self.standard_right_label.setText(right_label_text)


        self.yticks = [Location+i for i in range(count)]
        self.yticklabels = [str(np.power(10.0, (Location + i))) for i in range(count)]

        self.axes.set_yticks(self.yticks)
        self.axes.set_yticklabels(self.yticklabels, fontsize=6)


        #self.axes.set_yscale('log')

        self.axes.set_xticks(self.xticks)
        self.axes.set_xticklabels(self.xticklabels, rotation=-45, fontsize=6)






        self.canvas.draw()




        self.OutPutTitle='REE'

        #print(len(self.algebraDeltaEuList))

        self.OutPutData = pd.DataFrame(
            {'Label': self.LabelList,
             'Eu/Eu*(algebra)': self.algebraDeltaEuList,
             'Eu/Eu*(square)': self.geometricDeltaEuList,

             'Ce/Ce*(LaPr)': self.LaPrDeltaCeList,
             'Ce/Ce*(LaNd)': self.LaNdDeltaCeList,

             '(La/Sm)N':self.LaSmList,
             '(La/Yb)N':self.LaYbList,
             '(Gd/Yb)N':self.GdYbList,

             'trisection LREE': self.LREEList,
             'trisection MREE': self.MREEList,
             'trisection HREE': self.HREEList,
             'bisection LREE': self.BinLREEList,
             'bisection HREE': self.BinHREEList,
             'LREE/HREE':self.L_HREEList,

             'ALLREE': self.ALLREEList
             })

        #print('middle ',len(self.OutPutData['Eu/Eu*(algebra)']))


        '''
        self.LaPrDeltaCeList.append(firstCe)
        self.LaNdDeltaCeList.append(secondCe)
        '''

        self.OutPutFig=self.fig
self.LaPrDeltaCeList.append(firstCe)
        self.LaNdDeltaCeList.append(secondCe)