当前位置: 首页>>代码示例>>Python>>正文


Python NavigationToolbar2QT.clear方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.clear方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.clear方法的具体用法?Python NavigationToolbar2QT.clear怎么用?Python NavigationToolbar2QT.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_qt4.NavigationToolbar2QT的用法示例。


在下文中一共展示了NavigationToolbar2QT.clear方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

        
        """Customization for Qt Designer created window"""
    
        def ClearPlot(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.draw()
            
        def copy_to_clipboard(self):
            pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
            QtGui.QApplication.clipboard().setPixmap(pixmap)
            
            
        def Open_Geoplot(self):
            self.fname = QtGui.QFileDialog.getOpenFileName()
            
        def Plot_Function(self):
            #Get values from Options Grid
            grid_length = self.TravL_val.value()
            grid_width = self.GridL_val.value()
            sample_interval = self.TravI_val.value()
            traverse_interval = self.GridI_val.value()
            
            self.output = Load_Comp(self.fname,grid_length,grid_width,sample_interval,traverse_interval)
            self.mpl.canvas.ax.clear()
            print np.shape(self.output)
            self.mpl.canvas.ax.imshow(self.output,cmap=plt.cm.Greys,extent=[0,grid_length,grid_width,0], aspect='equal',interpolation='none',vmin = self.neg_val.value(), vmax = self.pos_val.value())                        
            self.mpl.canvas.draw()
            
        def Plot_Median_Filter(self):
            grid_length = self.TravL_val.value()
            grid_width = self.GridL_val.value()
            sample_interval = self.TravI_val.value()
            traverse_interval = self.GridI_val.value()
            
            self.output = Load_Comp(self.fname,grid_length,grid_width,sample_interval,traverse_interval)
            self.filter_output = median_filter(self.output)            
            self.mpl.canvas.ax.clear()
            print np.shape(self.output)
            self.mpl.canvas.ax.imshow(self.filter_output,cmap=plt.cm.Greys,extent=[0,grid_length,grid_width,0], aspect='equal',interpolation='none',vmin = self.neg_val.value(), vmax = self.pos_val.value())                        
            self.mpl.canvas.draw()
            
        def plot_options(self):
            self.neg_label = QtGui.QLabel('Neg Value', self)
            self.neg_val = QtGui.QDoubleSpinBox(self)
            self.neg_val.setRange(-100, 100)
            self.neg_val.setValue(-1)
            
            self.pos_label = QtGui.QLabel('Pos Value', self)            
            self.pos_val = QtGui.QDoubleSpinBox(self)
            self.pos_val.setRange(-100, 100)
            self.pos_val.setValue(2)
            
            self.TravL_label = QtGui.QLabel('Trav Length', self)
            self.TravL_val = QtGui.QDoubleSpinBox(self)
            self.TravL_val.setRange(0, 1000)
            self.TravL_val.setValue(30)
            
            self.TravI_label = QtGui.QLabel('Sample Interval', self)
            self.TravI_val = QtGui.QDoubleSpinBox(self)
            self.TravI_val.setValue(0.25)
            
            self.GridL_label = QtGui.QLabel('Grid Width', self)
            self.GridL_val = QtGui.QDoubleSpinBox(self)
            self.GridL_val.setRange(0, 1000)
            self.GridL_val.setValue(30)
            
            self.GridI_label = QtGui.QLabel('Traverse Interval', self)
            self.GridI_val = QtGui.QDoubleSpinBox(self)
            self.GridI_val.setValue(1)
            
            self.Grid_horizontal_Layout_1.addWidget(self.TravL_label)
            self.Grid_horizontal_Layout_1.addWidget(self.TravL_val)
            self.Grid_horizontal_Layout_1.addWidget(self.TravI_label)
            self.Grid_horizontal_Layout_1.addWidget(self.TravI_val)
            
            self.Grid_horizontal_Layout_2.addWidget(self.GridL_label)
            self.Grid_horizontal_Layout_2.addWidget(self.GridL_val)
            self.Grid_horizontal_Layout_2.addWidget(self.GridI_label)
            self.Grid_horizontal_Layout_2.addWidget(self.GridI_val)
            
            self.Grid_horizontal_Layout_3 = QtGui.QHBoxLayout()
            self.Grid_horizontal_Layout_3.setObjectName("Grid_horizontal_Layout_3")
            self.Options_Grid.addLayout(self.Grid_horizontal_Layout_3, 2, 0, 1, 1)
        
            self.Grid_horizontal_Layout_3.addWidget(self.neg_label)
            self.Grid_horizontal_Layout_3.addWidget(self.neg_val)
            self.Grid_horizontal_Layout_3.addWidget(self.pos_label)
            self.Grid_horizontal_Layout_3.addWidget(self.pos_val)
            
            
        def Button_Definitions(self):
            self.firstrun=True
            
            self.Open_button = QtGui.QPushButton('Open', self)
            self.fname = self.Open_button.clicked.connect(self.Open_Geoplot)
            self.Button_Layout.addWidget(self.Open_button)
            
            self.pushButton_plot.clicked.connect(self.Plot_Function)
#.........这里部分代码省略.........
开发者ID:ArchaeoPY,项目名称:ArchaeoPY,代码行数:103,代码来源:view_and_save_data_gui.py

示例2: TraverseMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class TraverseMainWindow(QtGui.QMainWindow, Ui_MainWindow):
    def ClearPlot(self):
        self.mpl.canvas.ax.clear()
        self.mpl.canvas.draw()

    def copy_to_clipboard(self):
        pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
        QtGui.QApplication.clipboard().setPixmap(pixmap)

    def press_open(self):
        self.fname = QtGui.QFileDialog.getExistingDirectory(self, "Select Project")
        open_project(self.fname, self)
        self.statusbar.showMessage("press_open returned")
        self.repaint()

    def Open_File(self):
        self.fname = QtGui.QFileDialog.getOpenFileName()
        # self.f = open(self.fname, 'rb')
        with open(self.fname, "r") as f:
            num_cols = len(f.readline().split("	")) - 1
            f.seek(0)
            data = np.genfromtxt(
                f, names=True, delimiter="	", dtype=None, filling_values=np.nan, usecols=(range(0, num_cols))
            )
            return data
        # print data
        # print "beak"
        # return data
        # print data
        # print "break"

    def top_data(self):
        # print "beak"
        self.top_data = self.Open_File()
        print self.top_data.dtype.names
        # print data
        self.top_x = self.top_data.dtype.names
        # print self.data[self.data.dtype.names[1]]
        # print self.data[self.data.dtype.names[2]]
        # return self.top_x
        self.top_y = self.top_data.dtype.names
        # return self.top_y
        self.top_xcombo.clear()
        self.top_xcombo.addItems(self.top_x)
        self.top_ycombo.clear()
        self.top_ycombo.addItems(self.top_y)

        # Clears Legend
        # self.legend_definitions()

    def legend_definitions(self):
        self.handles = []
        self.labels = []

        self.colors = itertools.cycle(["b", "g", "r", "c", "m", "y", "b"])
        self.markers = itertools.cycle([".", "D", "p", "*", "+"])

        self.legend = self.mpl.canvas.fig.legend(self.handles, self.labels, "upper right")

    def openInputDialog(self):
        x_axis, result = QtGui.QInputDialog.getText(self, "X axis", "Specify units")
        if result:
            self.x_axis = x_axis
        y_axis, result = QtGui.QInputDialog.getText(self, "Y axis", "Specify units")
        if result:
            self.y_axis = y_axis

    def button_grid(self):
        # An Expanding Spacer Item to be used anywhere..
        spacerItem = QtGui.QSpacerItem(40, 20, QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Minimum)
        self.toolbar_grid.addItem(spacerItem, 0, 0, 1, 1)
        self.toolbar_grid.addItem(spacerItem, 0, 4, 1, 1)

        # self.Grid_horizontal_Layout_2.addItem(spacerItem, 0)
        # self.Grid_horizontal_Layout_2.addItem(spacerItem, 4)

        # Layout for processing toolbbox
        self.top_plot_layout = QtGui.QGridLayout()
        self.top_plot_box = QtGui.QGroupBox()
        self.top_plot_box.setLayout(self.top_plot_layout)

        self.middle_plot_layout = QtGui.QGridLayout()
        self.middle_plot_box = QtGui.QGroupBox()
        self.middle_plot_box.setLayout(self.middle_plot_layout)

        self.bottom_plot_layout = QtGui.QGridLayout()
        self.bottom_plot_box = QtGui.QGroupBox()
        self.bottom_plot_box.setLayout(self.bottom_plot_layout)

        # Traverse selector grid box
        self.Grid_horizontal_Layout_2.addWidget(self.top_plot_box, 0)
        # self.toolbar_grid.addLayout(self.top_plot_layout, 0, 1, 1, 1)

        string = '<span style=" font-size:14pt;; font-weight:600;">Top Plot</span>'
        self.top_plot_layout_text = QtGui.QLabel(string, self)

        # Defines push buttons for top plot
        self.top_plot_buttons = QtGui.QButtonGroup()
        self.top_open_button = QtGui.QPushButton("Open", self)
        self.top_fname = self.top_open_button.clicked.connect(self.top_data)
#.........这里部分代码省略.........
开发者ID:Calorian,项目名称:ArchaeoPY,代码行数:103,代码来源:multiple_subplots_gui.py

示例3: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

        
        """Customization for Qt Designer created window"""
    
        def ClearPlot(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.draw()
            #Clears Legend
            self.legend.remove()
            self.legend_definitions()
            self.mpl.canvas.draw()
            
            
        def copy_to_clipboard(self):
            pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
            QtGui.QApplication.clipboard().setPixmap(pixmap)
        
        def Open_File(self):
            self.fname = QtGui.QFileDialog.getOpenFileName()
            #Opes File
            with open(self.fname, 'r') as f:
                num_cols = len(f.readline().split('	'))-1
                f.seek(0)
                self.data = np.genfromtxt(f, names=True, delimiter='	',dtype=None,filling_values = np.nan, usecols=(range(0,num_cols)))

            self.open_handler()


        def open_handler(self):
            if self.plot1_selector.isChecked():
                #Defines x and y values
                self.x1 = self.data.dtype.names
                self.y1 = self.data.dtype.names
                #Populates combo boxes with header names
                self.x1combo.clear()
                self.x1combo.addItems(self.x1)
                self.y1combo.clear()
                self.y1combo.addItems(self.y1)

            if self.plot2_selector.isChecked():
                #Defines x and y values
                self.x2 = self.data.dtype.names
                self.y2 = self.data.dtype.names
                #Populates combo boxes with header names
                self.x2combo.clear()
                self.x2combo.addItems(self.x2)
                self.y2combo.clear()
                self.y2combo.addItems(self.y2)

            if self.plot3_selector.isChecked():
                #Defines x and y values
                self.x3 = self.data.dtype.names
                self.y3 = self.data.dtype.names
                #Populates combo boxes with header names
                self.x3combo.clear()
                self.x3combo.addItems(self.x3)
                self.y3combo.clear()
                self.y3combo.addItems(self.y3)                        

            
        def Plot_Function(self):
            #self.mpl.canvas.fig.clear()
            #self.legend.remove()
            #Takes x and y values to plot from combo box selection
            self.x1val = self.data[self.data.dtype.names[self.x1combo.currentIndex()]]
            self.y1val = self.data[self.data.dtype.names[self.y1combo.currentIndex()]]
            self.x2val = self.data[self.data.dtype.names[self.x2combo.currentIndex()]]
            self.y2val = self.data[self.data.dtype.names[self.y2combo.currentIndex()]]
            self.x3val = self.data[self.data.dtype.names[self.x3combo.currentIndex()]]
            self.y3val = self.data[self.data.dtype.names[self.y3combo.currentIndex()]]            
            #self.yval = self.yval - np.median(self.yval)
            
            self.axes = self.canvas.fig.add_subplot

            self.plot1 = self.mpl.canvas.fig.add_subplot(3,1,1)
            self.plot2 = self.mpl.canvas.fig.add_subplot(3,1,2)
            self.plot3 = self.mpl.canvas.fig.add_subplot(3,1,3)            
            
            
            #Calculates stats info of y values
            #self.stats() 
         
            #self.plot1 = self.mpl.canvas.fig.add_subplot(3,1,1)
            #self.plot1.set_xlabel(self.x_units.text())
            #self.plot1.set_ylabel(self.y1_units.text(), size=15)
            self.plot1.axes.set_autoscale_on(True)
            self.plot1.axes.autoscale_view(True,True,True)
            self.plot1.plot(self.x1val,self.y1val)
            
            #self.plot2 = self.mpl.canvas.fig.add_subplot(3,1,2, sharex=self.plot1)
            #self.plot2.set_xlabel(self.x_units.text())
            #self.plot2.set_ylabel(self.y2_units.text(), size=15)
            self.plot2.plot(self.x2val,self.y2val)
            
            #self.plot3 = self.mpl.canvas.fig.add_subplot(3,1,3, sharex=self.plot1)
            #self.plot3.set_xlabel(self.x_units.text())
            #self.plot3.set_ylabel(self.y3_units.text(),size=15)
            self.plot3.plot(self.x3val, self.y3val)
            
#.........这里部分代码省略.........
开发者ID:ArchaeoPY,项目名称:ArchaeoPY,代码行数:103,代码来源:multi_plots_gui.py

示例4: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

        
        """Customization for Qt Designer created window"""
    
        def ClearPlot(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.draw()
            #Clears Legend
                       
        def copy_to_clipboard(self):
            pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
            QtGui.QApplication.clipboard().setPixmap(pixmap)
        
        def Open_File(self):
            self.fname = QtGui.QFileDialog.getOpenFileName()
            #Opes File
            with open(self.fname, 'r') as f:
                self.num_cols = len(f.readline().split(','))
                f.seek(0)
                self.array = np.genfromtxt(f, dtype=float, delimiter=',', skiprows=1, filling_values=np.nan)

            self.chart_title.clear() #Display file path in GUI
            self.chart_title.setText(self.fname)
            #print self.array


        def regrid(self): #Regrid CMD data
            array = self.array #set data
            num_cols = self.num_cols #set number of columns
            fname = self.fname #set filename
            if self.hcp_config.isChecked: #set Coil orientation
                config = 'HCP'
            else:
                config = 'VCP'
            grid = self.grid.text() #set grid(s) to be regridded
            samples_int = float(self.samples_int.text()) #Sampling Interval
            samples_start = float(self.samples_start.text()) #Sample starting position
            samples_stop = float(self.samples_stop.text()) #Sample ending position
            no_samples = (samples_stop - samples_start + samples_int) / samples_int #number of amples down the line     
            traverses_start = float(self.trav_start.text()) #Starting traverse number
            traverses_stop = float(self.trav_stop.text()) #Ending traverse number
            no_traverses = (traverses_stop - traverses_start + float(self.trav_int.text())) / float(self.trav_int.text()) #Number of traverses
            
            #Regrid data
            regrid_cmd(fname, config, grid, array, num_cols, samples_start, samples_stop, no_samples, traverses_start, traverses_stop, no_traverses)
            
                              
        def button_grid(self): #Defines button and layout 
            #self.firstrun=True
            self.buttons_layout = QtGui.QGridLayout()
            self.buttons_box = QtGui.QGroupBox()
            self.buttons_box.setLayout(self.buttons_layout)

            self.survey_layout = QtGui.QGridLayout()
            self.survey_box = QtGui.QGroupBox()
            self.survey_box.setLayout(self.survey_layout)
        
            #File Properties
            self.Grid_horizontal_Layout_2.addWidget(self.buttons_box, 1)
            string = '<span style=" font-size:10pt;; font-weight:600;">File Settings</span>'       
            self.buttons_layout_text = QtGui.QLabel(string, self)             
            
            self.buttons = QtGui.QButtonGroup()            
            self.open_button = QtGui.QPushButton('Open', self)
            self.buttons.addButton(self.open_button)
            self.open_button.clicked.connect(self.Open_File)
            self.regrid_button = QtGui.QPushButton('Regrid', self)
            self.buttons.addButton(self.regrid_button)
            self.regrid_button.clicked.connect(self.regrid)
            self.clear_button = QtGui.QPushButton('Clear', self)
            self.buttons.addButton(self.clear_button)
            self.clear_button.clicked.connect(self.ClearPlot)
            self.chart_title = QtGui.QLineEdit(self)
            self.config_lbl = QtGui.QLabel('Orientation', self)
            self.hcp_config = QtGui.QRadioButton('HCP', self)
            self.vcp_config = QtGui.QRadioButton('VCP', self)
            self.grid = QtGui.QLineEdit(self)
            self.grid.setText('Enter Grid Number')
            

            self.buttons_layout.addWidget(self.buttons_layout_text, 0,0,1,4)                      
            self.buttons_layout.addWidget(self.open_button, 1,0)
            self.buttons_layout.addWidget(self.regrid_button, 2,0)
            self.buttons_layout.addWidget(self.clear_button, 3,0)
            self.buttons_layout.addWidget(self.chart_title, 4,0)
            self.buttons_layout.addWidget(self.config_lbl, 1,1)
            self.buttons_layout.addWidget(self.hcp_config, 2,1)
            self.buttons_layout.addWidget(self.vcp_config, 3,1)
            self.buttons_layout.addWidget(self.grid, 4,1)
            

            #survey parameters
            self.Grid_horizontal_Layout_2.addWidget(self.survey_box, 1)
            string = '<span style=" font-size:10pt;; font-weight:600;">Survey Parameters</span>'       
            self.survey_layout_text = QtGui.QLabel(string, self)
            self.survey_buttons = QtGui.QButtonGroup()
                               
            self.samples_start_lbl = QtGui.QLabel('Samples Start Position')
            self.samples_start = QtGui.QLineEdit(self)
#.........这里部分代码省略.........
开发者ID:ArchaeoPY,项目名称:ArchaeoPY,代码行数:103,代码来源:cmd_regrid_gui.py

示例5: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

        
        """Customization for Qt Designer created window"""
    
        def ClearPlot(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.draw()
            
        def copy_to_clipboard(self):
            pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
            QtGui.QApplication.clipboard().setPixmap(pixmap)
            
            
        def Open_Geoplot(self):
            self.fname = QtGui.QFileDialog.getOpenFileName()
            self.Plot_Function()
            
        def Plot_Function(self):
            #Get values from Options Grid
            self.grid_length = self.TravL_val.value()
            self.grid_width = self.GridL_val.value()
            self.sample_interval = self.TravI_val.value()
            self.traverse_interval = self.GridI_val.value()
            
            self.output = Load_Comp(self.fname,self.grid_length,self.grid_width,self.sample_interval,self.traverse_interval)
            self.mpl.canvas.ax.clear()
            print np.shape(self.output)
            self.mpl.canvas.ax.imshow(self.output,cmap=plt.cm.Greys,extent=[0,self.grid_length,self.grid_width,0], aspect='equal',interpolation='none',vmin = self.neg_val.value(), vmax = self.pos_val.value())                        
            self.mpl.canvas.draw()

            
        def plot_options(self):
            self.neg_label = QtGui.QLabel('Neg Value', self)
            self.neg_val = QtGui.QDoubleSpinBox(self)
            self.neg_val.setRange(-100, 100)
            self.neg_val.setValue(-1)
            
            self.pos_label = QtGui.QLabel('Pos Value', self)            
            self.pos_val = QtGui.QDoubleSpinBox(self)
            self.pos_val.setRange(-100, 100)
            self.pos_val.setValue(2)
            
            self.TravL_label = QtGui.QLabel('Trav Length', self)
            self.TravL_val = QtGui.QDoubleSpinBox(self)
            self.TravL_val.setRange(0, 1000)
            self.TravL_val.setValue(30)
            
            self.TravI_label = QtGui.QLabel('Sample Interval', self)
            self.TravI_val = QtGui.QDoubleSpinBox(self)
            self.TravI_val.setValue(0.25)
            
            self.GridL_label = QtGui.QLabel('Grid Width', self)
            self.GridL_val = QtGui.QDoubleSpinBox(self)
            self.GridL_val.setRange(0, 1000)
            self.GridL_val.setValue(30)
            
            self.GridI_label = QtGui.QLabel('Traverse Interval', self)
            self.GridI_val = QtGui.QDoubleSpinBox(self)
            self.GridI_val.setValue(1)
            
            self.Scale_label  = QtGui.QLabel('Scale Value', self)
            self.Scale_val =QtGui.QDoubleSpinBox(self)
            self.Scale_val.setRange(1, 5000)
            self.Scale_val.setValue(500)
            
            self.Clip_label  = QtGui.QLabel('Clipping Value', self)
            self.Clip_val = QtGui.QDoubleSpinBox(self)
            self.Clip_val.setRange(0.1, 100)
            self.Clip_val.setValue(15)
            
            self.Grid_horizontal_Layout_1.addWidget(self.TravL_label)
            self.Grid_horizontal_Layout_1.addWidget(self.TravL_val)
            self.Grid_horizontal_Layout_1.addWidget(self.TravI_label)
            self.Grid_horizontal_Layout_1.addWidget(self.TravI_val)
            
            self.Grid_horizontal_Layout_2.addWidget(self.GridL_label)
            self.Grid_horizontal_Layout_2.addWidget(self.GridL_val)
            self.Grid_horizontal_Layout_2.addWidget(self.GridI_label)
            self.Grid_horizontal_Layout_2.addWidget(self.GridI_val)
            
            self.Grid_horizontal_Layout_3 = QtGui.QHBoxLayout()
            self.Grid_horizontal_Layout_3.setObjectName("Grid_horizontal_Layout_3")
            self.Options_Grid.addLayout(self.Grid_horizontal_Layout_3, 2, 0, 1, 1)
        
            self.Grid_horizontal_Layout_3.addWidget(self.neg_label)
            self.Grid_horizontal_Layout_3.addWidget(self.neg_val)
            self.Grid_horizontal_Layout_3.addWidget(self.pos_label)
            self.Grid_horizontal_Layout_3.addWidget(self.pos_val)
            
            self.Grid_horizontal_Layout_4 = QtGui.QHBoxLayout()
            self.Grid_horizontal_Layout_4.setObjectName("Grid_horizontal_Layout_4")
            self.Options_Grid.addLayout(self.Grid_horizontal_Layout_4, 3, 0, 1, 1)
            
            self.Grid_horizontal_Layout_4.addWidget(self.Scale_label)
            self.Grid_horizontal_Layout_4.addWidget(self.Scale_val)
            self.Grid_horizontal_Layout_4.addWidget(self.Clip_label)
            self.Grid_horizontal_Layout_4.addWidget(self.Clip_val)
            
            
#.........这里部分代码省略.........
开发者ID:ArchaeoPY,项目名称:ArchaeoPY,代码行数:103,代码来源:comp2dxf_gui.py

示例6: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

    """Customization for Qt Designer created window"""

    def ClearPlot(self):
        self.mpl.canvas.ax.clear()
        self.mpl.canvas.draw()
        # Clears Legend
        self.legend.remove()
        self.legend_definitions()
        self.mpl.canvas.draw()

    def copy_to_clipboard(self):
        pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
        QtGui.QApplication.clipboard().setPixmap(pixmap)

    def Open_File(self):
        self.fname = QtGui.QFileDialog.getOpenFileName()
        # Opes File
        with open(self.fname, "r") as f:
            num_cols = len(f.readline().split(","))
            f.seek(0)
            self.data = np.genfromtxt(
                f, names=True, delimiter=",", dtype=None, filling_values=np.nan, usecols=(range(0, num_cols))
            )

            print self.data
        # Defines x and y values
        self.x = self.data.dtype.names
        print self.x
        self.y = self.data.dtype.names
        # Populates combo boxes with header names
        self.xcombo.clear()
        self.xcombo.addItems(self.x)
        self.ycombo.clear()
        self.ycombo.addItems(self.y)

        # Clears Legend
        self.legend_definitions()

    """
        def Save_Stats(self):
            self.f = open(self.fname, 'rb')
            data = np.genfromtxt(self.f, skip_header=1)
            fname = QtGui.QFileDialog.getSaveFileName(self, 'Save File', 
               '*.csv')            
            output_text = np.column_stack((self.x,self.y))
            np.savetxt(str(fname),output_text,fmt ='%1.2f',delimiter=',', header = self.header)                        
"""

    def Plot_Function(self):
        self.legend.remove()
        # Takes x and y values to plot from combo box selection
        self.xval = self.data[self.data.dtype.names[self.xcombo.currentIndex()]]
        self.yval = self.data[self.data.dtype.names[self.ycombo.currentIndex()]]
        # self.yval = self.yval - np.median(self.yval)

        # Calculates stats info of y values
        self.stats()

        temp_scatter = self.mpl.canvas.ax.scatter(
            self.xval,
            self.yval,
            color=self.marker_colour.currentText(),
            marker=self.marker_style.currentText(),
            s=self.marker_size.value(),
        )
        self.handles.append(temp_scatter)
        self.labels.append(self.data.dtype.names[self.ycombo.currentIndex()])
        self.legend = self.mpl.canvas.fig.legend(self.handles, self.labels, "upper right")

        self.mpl.canvas.ax.set_ylim(ymin=np.min(self.yval), ymax=(np.max(self.yval)))
        self.mpl.canvas.ax.set_xlim(xmin=np.min(self.xval), xmax=np.max(self.xval))
        self.mpl.canvas.ax.set_autoscale_on(True)
        self.mpl.canvas.ax.autoscale_view(True, True, True)
        self.mpl.canvas.ax.set_xlabel(self.x_units.text(), size=15)
        self.mpl.canvas.ax.set_ylabel(self.y_units.text(), size=15)
        self.mpl.canvas.ax.set_title(self.chart_title.text(), size=20)
        # self.mpl.canvas.ax.axis('auto')

        # Creates scatter plot

        self.mpl.canvas.draw()

    def legend_definitions(self):  # Handles legend
        self.handles = []
        self.labels = []

        # self.colors = itertools.cycle(["b","g","r","c","m","y","b"])
        # self.markers = itertools.cycle([".","D","p","*","+"])

        self.legend = self.mpl.canvas.fig.legend(self.handles, self.labels, "upper right")

    def stats(self):  # Calculates stats info of y values and sends back to UI
        self.min = str(np.round(np.min(self.yval), decimals=3))
        self.min_output.setText(self.min)
        self.max = str(np.round(np.max(self.yval), decimals=3))
        self.max_output.setText(self.max)
        self.mean = str(np.round(np.mean(self.yval), decimals=3))
        self.mean_output.setText(self.mean)
#.........这里部分代码省略.........
开发者ID:Calorian,项目名称:ArchaeoPY,代码行数:103,代码来源:plotter_gui.py

示例7: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

        
        """Customization for Qt Designer created window"""
    
        def ClearPlot(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.draw()
            
        def copy_to_clipboard(self):
            pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
            QtGui.QApplication.clipboard().setPixmap(pixmap)
            
        def Open_File(self):
            self.fname = QtGui.QFileDialog.getOpenFileName()
            self.Image2Float()
            
        def Image2Float(self):
            self.f = open(self.fname, 'rb')
            self.image = io.imread(self.f)
            self.array = img_as_float(self.image)
            
        def Plot_Original_Image(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.ax.imshow(self.image)                        
            self.mpl.canvas.draw()
        
        def Plot_Function(self):
            self.output = cannyfilter(self.array) #Updated to imported module as necessary           
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.ax.imshow(self.output, cmap=plt.cm.gray)                        
            self.mpl.canvas.draw()
                        
        def Button_Definitions(self):
            self.firstrun=True
            
            self.Open_button = QtGui.QPushButton('Open', self)
            self.fname = self.Open_button.clicked.connect(self.Open_File)
            self.fname = self.Open_button.clicked.connect(self.Plot_Original_Image)
            self.Button_Layout.addWidget(self.Open_button)
            
            self.pushButton_plot.clicked.connect(self.Plot_Function)
            self.pushButton_clear.clicked.connect(self.ClearPlot)
            QtGui.QShortcut(QtGui.QKeySequence("Ctrl+P"),self, self.Plot_Function)
            
            QtGui.QShortcut(QtGui.QKeySequence("Ctrl+C"),self, self.copy_to_clipboard)
        
        def __init__(self, parent = None):
            # initialization of the superclass
            super(ArchaeoPYMainWindow, self).__init__(parent)
            # setup the GUI --> function generated by pyuic4
            self.setupUi(self)
            #Adds a Matplotlib Toolbar to the display, clears the display and adds only the required buttons
            self.navi_toolbar = NavigationToolbar(self.mpl.canvas, self)
            self.navi_toolbar.clear()
    
        #Adds Buttons
            a = self.navi_toolbar.addAction(self.navi_toolbar._icon('home.png'), 'Home',
                                            self.navi_toolbar.home)
            #a.setToolTip('returns axes to original position')
            a = self.navi_toolbar.addAction(self.navi_toolbar._icon('move.png'), 'Pan',
                                            self.navi_toolbar.pan)
            a.setToolTip('Pan axes with left mouse, zoom with right')
            a = self.navi_toolbar.addAction(self.navi_toolbar._icon('zoom_to_rect.png'), 'Zoom',
                                            self.navi_toolbar.zoom)
            a.setToolTip('Zoom to Rectangle')
            a = self.navi_toolbar.addAction(self.navi_toolbar._icon('filesave.png'), 'Save',
                               self.navi_toolbar.save_figure)
            a.setToolTip('Save the figure')
    
            #Button_layout is a QT desginer Grid Layout.
            self.toolbar_grid.addWidget(self.navi_toolbar)
            self.Button_Definitions()
开发者ID:dempseyg,项目名称:ArchaeoPY,代码行数:75,代码来源:scikit_functions_gui.py

示例8: ArchaeoPYMainWindow

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import clear [as 别名]
class ArchaeoPYMainWindow(QtGui.QMainWindow, Ui_MainWindow):

        
        """Customization for Qt Designer created window"""
    
        def ClearPlot(self):
            self.mpl.canvas.ax.clear()
            self.mpl.canvas.draw()
            #Clears Legend
            self.legend.remove()
            self.legend_definitions()
            self.mpl.canvas.draw()
            
            
        def copy_to_clipboard(self):
            pixmap = QtGui.QPixmap.grabWidget(self.mpl.canvas)
            QtGui.QApplication.clipboard().setPixmap(pixmap)
        
        def Open_File(self):
            self.fname = QtGui.QFileDialog.getOpenFileName()
            #Opes File
            with open(self.fname, 'r') as f:
                num_cols = len(f.readline().split('	'))-1
                f.seek(0)
                self.data = np.genfromtxt(f, names=True, delimiter='	',dtype=None,filling_values = np.nan, usecols=(range(0,num_cols)))

            #Defines x and y values
            self.x = self.data.dtype.names
            self.y = self.data.dtype.names
            self.z = self.data.dtype.names
            #Populates combo boxes with header names
            self.xcombo.clear()
            self.xcombo.addItems(self.x)
            self.ycombo.clear()
            self.ycombo.addItems(self.y)
            self.zcombo.clear()
            self.zcombo.addItems(self.z)            
            
            #Clears Legend
            #self.legend_definitions()
            
        '''
        def Save_Stats(self):
            self.f = open(self.fname, 'rb')
            data = np.genfromtxt(self.f, skip_header=1)
            fname = QtGui.QFileDialog.getSaveFileName(self, 'Save File', 
               '*.csv')            
            output_text = np.column_stack((self.x,self.y))
            np.savetxt(str(fname),output_text,fmt ='%1.2f',delimiter=',', header = self.header)                        
'''
        def grid_data(self):
            self.mpl.canvas.ax.clear()
            #Takes x and y values to plot from combo box selection
            self.xval = self.data[self.data.dtype.names[self.xcombo.currentIndex()]]
            self.yval = self.data[self.data.dtype.names[self.ycombo.currentIndex()]]
            self.zval = self.data[self.data.dtype.names[self.zcombo.currentIndex()]]
            self.x_int = float(self.xint_box.text())
            self.y_int = float(self.yint_box.text())
            
            

            #xi = np.arange(np.min(self.xval), np.max(self.xval), self.x_int)
            #yi = np.arange(np.min(self.yval), np.max(self.yval), self.y_int)
            #zi = griddata(self.xval, self.yval, self.zval, xi, yi, interp='nn')
            #print np.shape(zi)

            #self.mpl.canvas.ax.axis('auto')
            
            #Creates scatter plot
            self.mpl.canvas.ax.imshow(zi)
            self.mpl.canvas.draw()
            np.savetxt('test.txt', zi, delimiter='    ')
        
        def save_data(self):
            self.save_fname = QtGui.QFileDialog.getSaveFileName(self, 'Save Gridded Data', selectedFilter='*.txt')
        

        def stats(self): #Calculates stats info of y values and sends back to UI
            self.mean = str(np.round(np.mean(self.yval), decimals=3))
            self.mean_output.setText(self.mean)
            self.median = str(np.round(np.median(self.yval), decimals=3))
            self.median_output.setText(self.median)
            self.sd = str(np.round(np.std(self.yval), decimals=3))
            self.sd_output.setText(self.sd)
 
        def moving_average_buttons(self): #Radio Button Helper
            if self.rolling_mean_radio.isChecked():
                self.moving_mean()
            else:
                self.moving_median()
            
        def moving_mean(self):   
            self.trend_y= rolling_mean(self.yval, self.moving_avg_window.value())
            self.plot_trendline()
        
        def moving_median(self):
            self.trend_y = rolling_median(self.yval, self.moving_avg_window.value())
            self.plot_trendline()
        
                              
#.........这里部分代码省略.........
开发者ID:ArchaeoPY,项目名称:ArchaeoPY,代码行数:103,代码来源:EM_regrid_gui.py


注:本文中的matplotlib.backends.backend_qt4.NavigationToolbar2QT.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。