def Magic(self):

        #self.view.setFixedSize(self.width(), self.width())

        self.WholeData = []

        self.x_scale = self.width_plot / self.width_load

        self.y_scale = self.height_plot / self.height_load

        self.z_scale = self.depth_plot / self.depth_load


        # print(self.x_scale,' and ',self.x_scale)

        raw = self._df

        a = int(self.x_element.value())

        b = int(self.y_element.value())

        c = int(self.z_element.value())

        self.x_element_label.setText(self.items[a])
        self.y_element_label.setText(self.items[b])
        self.z_element_label.setText(self.items[c])


        if (self.Left != self.Right) and (self.Down != self.Up) and abs(self.Left) + abs(self.Right) + abs(
                self.Down) + abs(self.Up) != 0:
            self.extent = [self.Left, self.Right, self.Down, self.Up]
        elif (self.Left == self.Right and abs(self.Left) + abs(self.Right) != 0):
            reply = QMessageBox.warning(self, 'Warning', 'You set same value to Left and Right limits.')
            self.extent = 0

        elif (self.Down == self.Up and abs(self.Down) + abs(self.Up) != 0):
            reply = QMessageBox.warning(self, 'Warning', 'You set same value to Up and Down limits.')
            self.extent = 0
        else:
            self.extent = 0

        standardnamechosen = self.StandardsName[int(self.norm_slider.value())]
        standardchosen = self.Standards[standardnamechosen]

        self.norm_slider_label.setText(standardnamechosen)


        PointLabels = []
        XtoDraw = []
        YtoDraw = []
        ZtoDraw = []
        Colors=[]
        Alphas=[]
        Markers=[]
        Names=[]

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

            TmpLabel = ''

            #   self.WholeData.append(math.log(tmp, 10))

            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']

            x, y ,z = 0, 0, 0
            xuse, yuse,zuse = 0, 0, 0

            x, y,z = raw.at[i, self.items[a]], raw.at[i, self.items[b]],raw.at[i, self.items[c]]


            try:
                xuse = x
                yuse = y
                zuse = z

                self.xlabel = self.items[a]
                self.ylabel = self.items[b]
                self.zlabel = self.items[c]

                if (self.Normalize_cb.isChecked()):

                    self.xlabel = self.items[a] + ' Norm by ' + standardnamechosen
                    self.x_element_label.setText(self.xlabel)

                    self.ylabel = self.items[b] + ' Norm by ' + standardnamechosen
                    self.y_element_label.setText(self.ylabel)

                    self.zlabel = self.items[c] + ' Norm by ' + standardnamechosen
                    self.z_element_label.setText(self.zlabel)


                    if self.items[a] in self.Element:
                        xuse = xuse / standardchosen[self.items[a]]

                    if self.items[b] in self.Element:
                        yuse = yuse / standardchosen[self.items[b]]

                    if self.items[c] in self.Element:
                        zuse = zuse / standardchosen[self.items[c]]

                if (self.logx_cb.isChecked()):
                    xuse = math.log(x, 10)
                    self.xlabel = '$log10$ ' + self.xlabel


                if (self.logy_cb.isChecked()):
                    yuse = math.log(y, 10)

                    self.ylabel = '$log10$ ' + self.ylabel

                if (self.logz_cb.isChecked()):
                    zuse = math.log(z, 10)

                    self.zlabel = '$log10$ ' + self.zlabel

                XtoDraw.append(xuse)
                YtoDraw.append(yuse)
                ZtoDraw.append(zuse)
                Colors.append(raw.at[i, 'Color'])
                Alphas.append(raw.at[i, 'Alpha'])
                Names.append(raw.at[i, 'Label'])
                Markers.append(raw.at[i, 'Marker'])


            except(ValueError):
                pass


        if self.LimSet==False:
            self.Xleft, self.Xright, self.Ydown, self.Yup, self.Tail, self.Head = min(XtoDraw), max(XtoDraw), min(YtoDraw), max(YtoDraw), min(ZtoDraw), max(ZtoDraw)





        xmin, xmax = min(XtoDraw), max(XtoDraw)
        ymin, ymax = min(YtoDraw), max(YtoDraw)
        zmin, zmax = min(ZtoDraw), max(ZtoDraw)

        xmean = np.mean(XtoDraw)
        ymean = np.mean(YtoDraw)
        zmean = np.mean(ZtoDraw)

        Xoriginal = np.arange(xmin, xmax, (xmax - xmin) / 10)
        Yoriginal = np.arange(ymin, ymax, (ymax - ymin) / 10)
        Zoriginal = np.arange(zmin, zmax, (zmax - zmin) / 10)

        XonPlot = self.GetASequence(tail=self.ShapeGroups)
        YonPlot = self.GetASequence(tail=self.ShapeGroups)
        ZonPlot = self.GetASequence(tail=self.ShapeGroups)

        XonStick = []
        YonStick = []
        ZonStick = []

        for i in range(len(XonPlot)):
            XonStick.append([XonPlot[i], Xoriginal[i]])
            YonStick.append([YonPlot[i], Yoriginal[i]])
            ZonStick.append([ZonPlot[i], Zoriginal[i]])
            pass




        #print(XtoDraw,'\n', YtoDraw,'\n', ZtoDraw)

        toDf = {self.xlabel:XtoDraw,
                self.ylabel:YtoDraw,
                self.zlabel:ZtoDraw}




        newdf = pd.DataFrame(toDf)

        pos = newdf.as_matrix()

        print(pos)

        ThreeDimView = gl.GLScatterPlotItem(pos=pos, color=(100, 255, 255, 88), size=0.1, pxMode=False)


        print(xmean,'\n', ymean,'\n', zmean,'\n')

        self.view.pan(xmean, ymean, zmean)


        xgrid = gl.GLGridItem(size=QtGui.QVector3D(10, 10, 1), color=1)
        ygrid = gl.GLGridItem(size=QtGui.QVector3D(20, 20, 2), color=2)
        zgrid = gl.GLGridItem(size=QtGui.QVector3D(30, 30, 3), color=3)

        ## rotate x and y grids to face the correct direction
        xgrid.rotate(90, 0, 1, 0)
        ygrid.rotate(90, 1, 0, 0)



        xgrid.translate(xmean, ymean, zmean)
        ygrid.translate(xmean, ymean, zmean)
        zgrid.translate(xmean, ymean, zmean)


        ## scale each grid differently

        '''
        xgrid.scale(12.8, 12.8, 12.8)
        ygrid.scale(12.8, 12.8, 12.8)
        zgrid.scale(12.8, 12.8, 12.8)
        '''

        # xgrid.setTransform(xmean,ymean,zmean)

        self.view.addItem(xgrid)
        self.view.addItem(ygrid)
        self.view.addItem(zgrid)
        self.view.addItem(ThreeDimView)
def Magic ( self ) : self . WholeData = [ ] self . x_scale = self . width_plot / self . width_load self . y_scale = self . height_plot / self . height_load self . z_scale = self . depth_plot / self . depth_load raw = self . _df a = int ( self . x_element . value ( ) ) b = int ( self . y_element . value ( ) ) c = int ( self . z_element . value ( ) ) self . x_element_label . setText ( self . items [ a ] ) self . y_element_label . setText ( self . items [ b ] ) self . z_element_label . setText ( self . items [ c ] ) if ( self . Left != self . Right ) and ( self . Down != self . Up ) and abs ( self . Left ) + abs ( self . Right ) + abs ( self . Down ) + abs ( self . Up ) != 0 : self . extent = [ self . Left , self . Right , self . Down , self . Up ] elif ( self . Left == self . Right and abs ( self . Left ) + abs ( self . Right ) != 0 ) : reply = QMessageBox . warning ( self , 'Warning' , 'You set same value to Left and Right limits.' ) self . extent = 0 elif ( self . Down == self . Up and abs ( self . Down ) + abs ( self . Up ) != 0 ) : reply = QMessageBox . warning ( self , 'Warning' , 'You set same value to Up and Down limits.' ) self . extent = 0 else : self . extent = 0 standardnamechosen = self . StandardsName [ int ( self . norm_slider . value ( ) ) ] standardchosen = self . Standards [ standardnamechosen ] self . norm_slider_label . setText ( standardnamechosen ) PointLabels = [ ] XtoDraw = [ ] YtoDraw = [ ] ZtoDraw = [ ] Colors = [ ] Alphas = [ ] Markers = [ ] Names = [ ] for i in range ( len ( raw ) ) : TmpLabel = '' 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' ] x , y , z = 0 , 0 , 0 xuse , yuse , zuse = 0 , 0 , 0 x , y , z = raw . at [ i , self . items [ a ] ] , raw . at [ i , self . items [ b ] ] , raw . at [ i , self . items [ c ] ] try : xuse = x yuse = y zuse = z self . xlabel = self . items [ a ] self . ylabel = self . items [ b ] self . zlabel = self . items [ c ] if ( self . Normalize_cb . isChecked ( ) ) : self . xlabel = self . items [ a ] + ' Norm by ' + standardnamechosen self . x_element_label . setText ( self . xlabel ) self . ylabel = self . items [ b ] + ' Norm by ' + standardnamechosen self . y_element_label . setText ( self . ylabel ) self . zlabel = self . items [ c ] + ' Norm by ' + standardnamechosen self . z_element_label . setText ( self . zlabel ) if self . items [ a ] in self . Element : xuse = xuse / standardchosen [ self . items [ a ] ] if self . items [ b ] in self . Element : yuse = yuse / standardchosen [ self . items [ b ] ] if self . items [ c ] in self . Element : zuse = zuse / standardchosen [ self . items [ c ] ] if ( self . logx_cb . isChecked ( ) ) : xuse = math . log ( x , 10 ) self . xlabel = '$log10$ ' + self . xlabel if ( self . logy_cb . isChecked ( ) ) : yuse = math . log ( y , 10 ) self . ylabel = '$log10$ ' + self . ylabel if ( self . logz_cb . isChecked ( ) ) : zuse = math . log ( z , 10 ) self . zlabel = '$log10$ ' + self . zlabel XtoDraw . append ( xuse ) YtoDraw . append ( yuse ) ZtoDraw . append ( zuse ) Colors . append ( raw . at [ i , 'Color' ] ) Alphas . append ( raw . at [ i , 'Alpha' ] ) Names . append ( raw . at [ i , 'Label' ] ) Markers . append ( raw . at [ i , 'Marker' ] ) except ( ValueError ) : pass if self . LimSet == False : self . Xleft , self . Xright , self . Ydown , self . Yup , self . Tail , self . Head = min ( XtoDraw ) , max ( XtoDraw ) , min ( YtoDraw ) , max ( YtoDraw ) , min ( ZtoDraw ) , max ( ZtoDraw ) xmin , xmax = min ( XtoDraw ) , max ( XtoDraw ) ymin , ymax = min ( YtoDraw ) , max ( YtoDraw ) zmin , zmax = min ( ZtoDraw ) , max ( ZtoDraw ) xmean = np . mean ( XtoDraw ) ymean = np . mean ( YtoDraw ) zmean = np . mean ( ZtoDraw ) Xoriginal = np . arange ( xmin , xmax , ( xmax - xmin ) / 10 ) Yoriginal = np . arange ( ymin , ymax , ( ymax - ymin ) / 10 ) Zoriginal = np . arange ( zmin , zmax , ( zmax - zmin ) / 10 ) XonPlot = self . GetASequence ( tail = self . ShapeGroups ) YonPlot = self . GetASequence ( tail = self . ShapeGroups ) ZonPlot = self . GetASequence ( tail = self . ShapeGroups ) XonStick = [ ] YonStick = [ ] ZonStick = [ ] for i in range ( len ( XonPlot ) ) : XonStick . append ( [ XonPlot [ i ] , Xoriginal [ i ] ] ) YonStick . append ( [ YonPlot [ i ] , Yoriginal [ i ] ] ) ZonStick . append ( [ ZonPlot [ i ] , Zoriginal [ i ] ] ) pass toDf = { self . xlabel : XtoDraw , self . ylabel : YtoDraw , self . zlabel : ZtoDraw } newdf = pd . DataFrame ( toDf ) pos = newdf . as_matrix ( ) print ( pos ) ThreeDimView = gl . GLScatterPlotItem ( pos = pos , color = ( 100 , 255 , 255 , 88 ) , size = 0.1 , pxMode = False ) print ( xmean , '\n' , ymean , '\n' , zmean , '\n' ) self . view . pan ( xmean , ymean , zmean ) xgrid = gl . GLGridItem ( size = QtGui . QVector3D ( 10 , 10 , 1 ) , color = 1 ) ygrid = gl . GLGridItem ( size = QtGui . QVector3D ( 20 , 20 , 2 ) , color = 2 ) zgrid = gl . GLGridItem ( size = QtGui . QVector3D ( 30 , 30 , 3 ) , color = 3 ) xgrid . rotate ( 90 , 0 , 1 , 0 ) ygrid . rotate ( 90 , 1 , 0 , 0 ) xgrid . translate ( xmean , ymean , zmean ) ygrid . translate ( xmean , ymean , zmean ) zgrid . translate ( xmean , ymean , zmean ) '''
        xgrid.scale(12.8, 12.8, 12.8)
        ygrid.scale(12.8, 12.8, 12.8)
        zgrid.scale(12.8, 12.8, 12.8)
        ''' self . view . addItem ( xgrid ) self . view . addItem ( ygrid ) self . view . addItem ( zgrid ) self . view . addItem ( ThreeDimView )
xgrid.scale(12.8, 12.8, 12.8)
        ygrid.scale(12.8, 12.8, 12.8)
        zgrid.scale(12.8, 12.8, 12.8)