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


Python FigureCanvasQTAgg.size方法代码示例

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


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

示例1: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    def __init__(self, scrollAreaWidgetContents, name):         
        QtGui.QWidget.__init__(self)
        self.setParent(scrollAreaWidgetContents)
        fig = Figure((3.0, 2.0), dpi=100)
        canvas = FigureCanvas(fig)
        canvas.setParent(self)
        toolbar = myNavigationToolbar(canvas, self)
        axes = fig.add_subplot(111)
        axes.autoscale(True)
        axes.set_yscale('log')
        axes.set_title(name)
        axes.set_xlabel('Time [s]')
        axes.set_ylabel('|R|')

         # place plot components in a layout
        plotLayout = QtGui.QVBoxLayout()
        plotLayout.addWidget(canvas)
        plotLayout.addWidget(toolbar)
        self.setLayout(plotLayout)
        
        self.dataPlot = []
        self.dirList = []
        self.dirType = 'Residuals'
        self.lastPos = -1
        self.name = name
        self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
        
        # prevent the canvas to shrink beyond a point
        #original size looks like a good minimum size
        canvas.setMinimumSize(canvas.size())
开发者ID:leytzher,项目名称:petroSym,代码行数:32,代码来源:figureResiduals.py

示例2: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    def __init__(self, scrollAreaWidgetContents, dataname, currentFolder):         
        QtGui.QWidget.__init__(self)
        self.setParent(scrollAreaWidgetContents)
        fig = Figure((3.0, 2.0), dpi=100)
        canvas = FigureCanvas(fig)
        canvas.setParent(self)
        toolbar = myNavigationToolbar(canvas, self)
        temporal_toolbar = temporalNavigationToolbar(canvas, self)
        axes = fig.add_subplot(111)
        axes.autoscale(True)
        axes.set_yscale('log')
        axes.set_title(dataname)
        
         # place plot components in a layout
        plotLayout = QtGui.QVBoxLayout()
        plotLayout.addWidget(temporal_toolbar)
        plotLayout.addWidget(canvas,1)
        plotLayout.addWidget(toolbar,0,QtCore.Qt.AlignCenter)
        self.setLayout(plotLayout)

        canvas.setMinimumSize(canvas.size())
        
        self.name = dataname
        self.dirList = []
        self.dirType = 'Sampled Line'
        self.lastPos = -1
        self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
        self.labels = ['x','y','z']
        self.currentFolder = currentFolder
        filename = '%s/system/controlDict'%(self.currentFolder)
        parsedData = ParsedParameterFile(filename,createZipped=False)
        self.ifield=parsedData['functions'][dataname]['fields'][0]
        self.archifield = 'data_%s.xy'%self.ifield
开发者ID:jmarcelogimenez,项目名称:petroSym,代码行数:35,代码来源:figureSampledLine.py

示例3: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    def __init__(self, scrollAreaWidgetContents, dataname):         
        QtGui.QWidget.__init__(self)
        self.setParent(scrollAreaWidgetContents)
        fig = Figure((3.0, 2.0), dpi=100)
        canvas = FigureCanvas(fig)
        canvas.setParent(self)
        toolbar = myNavigationToolbar(canvas, self)
        temporal_toolbar = temporalNavigationToolbar(canvas, self)
        axes = fig.add_subplot(111)
        axes.autoscale(True)
        axes.set_yscale('log')
        axes.set_title(dataname)
        
         # place plot components in a layout
        plotLayout = QtGui.QVBoxLayout()
        plotLayout.addWidget(temporal_toolbar)
        plotLayout.addWidget(canvas)
        plotLayout.addWidget(toolbar)
        self.setLayout(plotLayout)

        canvas.setMinimumSize(canvas.size())
        
        self.name = dataname
        self.dirList = []
        self.dirType = 'Sampled Line'
        self.lastPos = -1
        self.colors = ['r', 'b', 'k', 'g', 'y', 'c']
        self.labels = ['_x','_y','_z']
开发者ID:jmarcelogimenez,项目名称:petroFoam,代码行数:30,代码来源:figureSampledLine.py

示例4: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    def __init__(self, scrollAreaWidgetContents, currentFolder):         
        QtGui.QWidget.__init__(self)
        self.setParent(scrollAreaWidgetContents)
        
        canvas = FigureCanvas(Figure((3.0, 2.0), dpi=100))
        canvas.setParent(self)
        toolbar = myNavigationToolbar(canvas, self)
        toolbar.disableButtons()
        temporal_toolbar = temporalNavigationToolbar(canvas, self)

        mainImage = QtGui.QLabel(self)
        mainImage.setText(_fromUtf8(""))
        mainImage.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/fromHelyx/emptyFigure.png")))
        mainImage.setObjectName(_fromUtf8("mainImage"))
        mainImage.setScaledContents(True)
        mainImage.setSizePolicy(QtGui.QSizePolicy.Ignored,QtGui.QSizePolicy.Ignored)


        plotLayout = QtGui.QVBoxLayout()
        plotLayout.addWidget(temporal_toolbar)
        plotLayout.addWidget(mainImage,1)
        plotLayout.addWidget(toolbar,0,QtCore.Qt.AlignCenter)
        
        self.setLayout(plotLayout)
        self.lastPos = -1
        self.dirList = []
        self.currentFolder = currentFolder

        canvas.setMinimumSize(canvas.size())
开发者ID:jmarcelogimenez,项目名称:petroSym,代码行数:31,代码来源:figureGeneralSnapshot.py

示例5: plot_file

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
def plot_file(fps, base_dir, string_graph_map):
    app = QtGui.QApplication('Bodysim')
    graph_map = ast.literal_eval(string_graph_map)

    # Find the length of the simulation by looking at trajectory results.
    start_frame = 1
    count = 0
    with open(base_dir + os.sep + 'Trajectory' + os.sep + graph_map.keys()[0] + '.csv') as f:
        iterF = iter(f)
        # Skip header
        next(iterF)
        line = next(iterF)
        start_frame = float(line.split(',')[0])
        count = sum(1 for line in iterF)

    frame = MainWindow(start_frame, count)

    for sensor in graph_map:
        layout_contents = frame.add_tab(sensor)
        for plugin in graph_map[sensor]:
            data = get_data(base_dir + os.sep + plugin + os.sep + sensor + '.csv')
            for variable_group in graph_map[sensor][plugin]:
                qfigWidget = QtGui.QWidget(layout_contents[1])
                fig = Figure((5.0, 4.0), dpi=100)
                canvas = FigureCanvas(fig)
                canvas.setParent(qfigWidget)
                toolbar = NavigationToolbar(canvas, qfigWidget)
                axes = fig.add_subplot(111)
                axes.set_title(plugin + ' ' + variable_group[2])
                yDatum = [data[variable[1]] for variable in graph_map[sensor][plugin][variable_group]]
                yLabels = [variable[0] for variable in graph_map[sensor][plugin][variable_group]]
                for i in range(len(yDatum)):
                    axes.plot(data[0], yDatum[i], label=yLabels[i])
                axes.grid(True)
                axes.legend()
                axes.autoscale(enable=False, axis='both')
                axes.set_xlabel(variable_group[0])
                axes.set_ylabel(variable_group[1])

                # Place plot components in a layout
                plotLayout = QtGui.QVBoxLayout()
                plotLayout.addWidget(canvas)
                plotLayout.addWidget(toolbar)
                qfigWidget.setLayout(plotLayout)
                frame.toolbars[fig] = toolbar
                frame.plots.append(axes)

                canvas.setMinimumSize(canvas.size())
                frame.bind_to_onclick_event(fig)
                layout_contents[0].addWidget(qfigWidget)

    frame.show()
    sys.exit(app.exec_())
开发者ID:uva-bodysim,项目名称:BodySim,代码行数:55,代码来源:qt_plotter.py

示例6: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    def __init__(self, scrollAreaWidgetContents):         
        QtGui.QWidget.__init__(self)
        self.setParent(scrollAreaWidgetContents)
        
        canvas = FigureCanvas(Figure((3.0, 2.0), dpi=100))
        canvas.setParent(self)
        toolbar = myNavigationToolbar(canvas, self)
        toolbar.disableButtons()
        temporal_toolbar = temporalNavigationToolbar(canvas, self)

        mainImage = QtGui.QLabel(self)
        mainImage.setText(_fromUtf8(""))
        mainImage.setPixmap(QtGui.QPixmap(_fromUtf8(":/newPrefix/images/fromHelyx/emptyFigure.png")))
        mainImage.setObjectName(_fromUtf8("mainImage"))

        plotLayout = QtGui.QVBoxLayout()
        plotLayout.addWidget(temporal_toolbar)
        plotLayout.addWidget(mainImage)
        plotLayout.addWidget(toolbar)
        
        self.setLayout(plotLayout)

        canvas.setMinimumSize(canvas.size())
开发者ID:jmarcelogimenez,项目名称:petroFoam,代码行数:25,代码来源:figureGeneralSnapshot.py

示例7: GUI

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]

#.........这里部分代码省略.........
        # load ecdysis data
        index = np.where( ecd[:,0] == float(self.worm[1:]) )
        mintp = np.min( [ i for i in ecd[index, 1:6][0][0] if i >= 0 ] )
        lethtidx = ecd[ index, 2:6 ][0][0] - 1
        tpL2 = self.timesDF.ix[ self.timesDF.tidxRel == lethtidx[0], 'timesRel' ].values[0]
        tpL1 = self.timesDF.ix[ self.timesDF.tidxRel == mintp, 'timesRel' ].values[0]

        # relative to hatching time
        self.tpHatch=tpL1

        ### if the cellPos pickle file already exists, load it, otherwise create a blank one
        if os.path.isfile( os.path.join(self.path, self.worm + '_04cellPos.pickle' ) ):
            self.cellPosDF = load_data_frame( self.path, self.worm + '_04cellPos.pickle' )
        
        else:
            self.cellPosDF = create_cell_pos( self.timesDF, self.cellNames )

        # detect available channels
        self.channels = []
        chns = ['CoolLED','488nm','561nm']
        for c in chns:

            if os.path.isfile( os.path.join( self.pathDial, c + '_movie.tif' ) ):

                self.channels.append(c)
        self.currentChannel = self.channels[0]

        ### detect size of the cropped images
        tp = np.min( self.gpDF.ix[ pd.notnull( self.gpDF.X ), 'tidx' ] )
        self.prevtp = tp-1
        tRow = self.timesDF.ix[ self.timesDF.tidxRel == tp ].squeeze()
        fileName = os.path.join( self.pathDial, tRow.fName + self.currentChannel + '.tif')
        firststack = load_stack( fileName )
        self.cropsize = firststack.shape[1]
        self.nslices = firststack.shape[0]

        ### load CoolLED movie
        if 'CoolLED' in self.channels:
            self.LEDmovie = load_stack( os.path.join( self.pathDial, 'CoolLED_movie.tif' ) )
        else:
            self.LEDmovie = load_stack( os.path.join( self.pathDial, self.currentChannel + '_movie.tif' ) )
        self.initializeCanvas1()
        self.initializeCanvas2()

        ### extract current cells already labeled
        self.currentCells = extract_current_cell_pos( self.cellPosDF, self.tp.value() )

        ### update the text of the fileName
        self.fName.setText( self.timesDF.ix[ self.timesDF.tidxRel == tp, 'fName' ].values[0])

        ### set the timepoint to the hatching time
        self.tp.setMinimum(np.min(self.timesDF.tidxRel))
        self.tp.setMaximum(np.max(self.timesDF.tidxRel))

        ### set the max slice number
        self.sl.setMaximum( self.nslices-1 )

        self.tp.setValue( tp )

        if self.currentChannel == 'CoolLED':
            self.CoolLEDBtn.setChecked(True)    # this uppdates the canvas1 once more
        elif self.currentChannel == '561nm':
            self._561nmBtn.setChecked(True)    # this uppdates the canvas1 once more
        elif self.currentChannel == '488nm':
            self._488nmBtn.setChecked(True)    # this uppdates the canvas1 once more
开发者ID:nicolagritti,项目名称:ACVU_scripts,代码行数:69,代码来源:04markCells.py

示例8: Amoeba_Line_Graph

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
class Amoeba_Line_Graph():

    def __init__(self):
        """
        This class is for the plot on each of the parameter UIs.
        """
        #Generate plot
        x = []
        y = []
        self.fig = Figure(figsize=(8,4),dpi=72, facecolor=(1,1,1), edgecolor=(0,0,0))
        self.sub_plot = self.fig.add_subplot(111)
        self.sub_plot.xaxis_date()
        if AMOEBA_LINE_GRAPH_DEBUG:
            print "X = "
            print x
            print "Y = "
            print y
            print "Create "
            print self.sub_plot.plot
        self.sub_plot.plot(y,x,'b')
        self.sub_plot.set_xlabel('Time')
        self.fig.autofmt_xdate()
        #Create canvas for the plot
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setMinimumSize(self.canvas.size())

    def update(self,datay,datax):
        """
        This method updates the plot with the input data.
        :param datay: Y axis of the points to plot.
        :param datax: X axis of the points to plot.
        """
        if AMOEBA_LINE_GRAPH_DEBUG:
            print "Update sub plot"
            print "X = "
            print datax
            print "Y = "
            print datay
            print "Update "
            print self.sub_plot.plot
        # Clear the graph.
        self.clear_graph()
        self.sub_plot.plot(datax,datay,'b')
        self.sub_plot.set_visible(True)
        self.sub_plot.autoscale(True,"both")
        self.canvas.draw()
        
    def retrieve_graph(self):
        """
        This method returns the plot's widget.
        :return:
        """
        return self.canvas

    def clear_graph(self):
        """
        This method clears the graph.
        """
        y = []
        x = []
        self.sub_plot.clear()
        self.sub_plot.set_visible(True)
        self.sub_plot.autoscale(True,"both",False)
        self.sub_plot.plot(y,x,'b')
        self.canvas.draw()
开发者ID:gilgad2000,项目名称:AmoebStable,代码行数:67,代码来源:AmoebaSensorTab.py

示例9: ImageViewer

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    import sys

    app = QtGui.QApplication(sys.argv)
    imageViewer = ImageViewer()
    imageViewer.show()
    
    figure = plt.figure()
    figure.set_size_inches(11, 8.5)
    figure.patch.set_facecolor('white')
    plt.plot([1, 2, 3, 4], [1, 2, 3, 4], '-b')

    figure_canvas = FigureCanvasQTAgg(figure)
    figure_canvas.draw()
            
    size = figure_canvas.size()
    width, height = size.width(), size.height()
    print(width, height)
    print(figure_canvas.get_width_height())
    imgbuffer = figure_canvas.buffer_rgba()
    image = QtGui.QImage(imgbuffer, width, height,
                         QtGui.QImage.Format_ARGB32)
                         
    # Reference for the RGB to BGR swap:
    # http://sourceforge.net/p/matplotlib/mailman/message/5194542/
      
    image = QtGui.QImage.rgbSwapped(image)    
    imageViewer.load_image(image, 0)
    
    
    sys.exit(app.exec_())
开发者ID:jpdrolet19,项目名称:WHAT,代码行数:32,代码来源:mplFigViewer.py

示例10: GUI

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
class GUI(QtGui.QWidget):
    
    #-----------------------------------------------------------------------------------------------
    # INITIALIZATION OF THE WINDOW - DEFINE AND PLACE ALL THE WIDGETS
    #-----------------------------------------------------------------------------------------------

    def __init__(self):

        super(GUI, self).__init__()
        
        self.setWindowTitle('Seam Cells Analysis')
        self.scaleFactor = 4
        self.side = 'L'
        self.lbltxt = '"wheel" press: change side, currently %s\n"i" or "u" press: change cell sides'
        self.initUI()
        
    def initUI(self):
        
        # SET THE GEOMETRY
        
        mainWindow = QtGui.QVBoxLayout()
        mainWindow.setSpacing(15)
        
        fileBox = QtGui.QHBoxLayout()
        spaceBox1 = QtGui.QHBoxLayout()
        rawDataBox = QtGui.QHBoxLayout()
        spaceBox2 = QtGui.QHBoxLayout()
        straightBox = QtGui.QVBoxLayout()
        
        mainWindow.addLayout(fileBox)
        mainWindow.addLayout(spaceBox1)
        mainWindow.addLayout(rawDataBox)
        mainWindow.addLayout(spaceBox2)
        mainWindow.addLayout(straightBox)
        
        Col1 = QtGui.QGridLayout()
        Col2 = QtGui.QHBoxLayout()
        Col3 = QtGui.QVBoxLayout()
        Col4 = QtGui.QVBoxLayout()
        
        rawDataBox.addLayout(Col1)
        rawDataBox.addLayout(Col2)
        rawDataBox.addLayout(Col3)
        rawDataBox.addLayout(Col4)
        
        Raw1 = QtGui.QHBoxLayout()
        Raw2 = QtGui.QHBoxLayout()
        Raw3 = QtGui.QHBoxLayout()

        straightBox.addLayout(Raw1)
        straightBox.addLayout(Raw2)
        straightBox.addLayout(Raw3)

        self.setLayout(mainWindow)

        # DEFINE ALL WIDGETS AND BUTTONS
        
        loadBtn = QtGui.QPushButton('Load DataSet')
        saveBtn = QtGui.QPushButton('Save data (F12)')
        
        tpLbl = QtGui.QLabel('Timepoint:')
        slLbl = QtGui.QLabel('Slice:')
        hatchLbl = QtGui.QLabel('Hatching Time:')
        
        self.tp = QtGui.QSpinBox(self)
        self.tp.setValue(0)
        self.tp.setMaximum(100000)
        
        self.sl = QtGui.QSpinBox(self)
        self.sl.setValue(0)
        self.sl.setMaximum(100000)
        
        self.hatch = QtGui.QSpinBox(self)
        self.hatch.setValue(0)
        self.hatch.setMaximum(100000)
        
        self._488nmBtn = QtGui.QRadioButton('488nm')
        self._561nmBtn = QtGui.QRadioButton('561nm')
        self.CoolLEDBtn = QtGui.QRadioButton('CoolLED')
        
        automaticOutlineBtn = QtGui.QPushButton('Automatic Outline')
        straightenBtn = QtGui.QPushButton('Straighten images')
        
        self.sld1 = QtGui.QSlider(QtCore.Qt.Vertical, self)
        self.sld1.setMaximum(2**16-1)
        self.sld1.setValue(0)
        self.sld2 = QtGui.QSlider(QtCore.Qt.Vertical, self)
        self.sld2.setMaximum(2**16)
        self.sld2.setValue(2**16-1)

        self.fig1 = Figure((8.0, 8.0), dpi=100)
        self.fig1.subplots_adjust(left=0., right=1., top=1., bottom=0.)
        self.ax1 = self.fig1.add_subplot(111)
        self.canvas1 = FigureCanvas(self.fig1)
        self.canvas1.setFocusPolicy( QtCore.Qt.ClickFocus )
        self.canvas1.setFocus()
        self.canvas1.setFixedSize(QtCore.QSize(500,500)) ############################# change this value to set the figure size
        self.canvas1.setSizePolicy( QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding )

        self.cellTbl = QtGui.QTableWidget()
#.........这里部分代码省略.........
开发者ID:jvzonlab,项目名称:timelapse-natcomm-2016,代码行数:103,代码来源:GUI_oscillation.py

示例11: GUI

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]

#.........这里部分代码省略.........
            self.changeSpaceTime( 'time', -1 )

        # change slice
        elif event.key() == QtCore.Qt.Key_Up:
            self.changeSpaceTime( 'space', +1 )
            
        elif event.key() == QtCore.Qt.Key_Down:
            self.changeSpaceTime( 'space', -1 )

        # key press on cropped image
        if self.canvas1.underMouse():
            self.onKeyPressOnCanvas1(event)
            
        self.setFocus()

    def wheelEvent(self,event):
        if self.canvas1.underMouse():
            step = event.step
        else:          
            step = event.delta()/abs(event.delta())
        self.sl.setValue( self.sl.value() + step) 

    #-----------------------------------------------------------------------------------------------
    # ADDITIONAL FUNCTIONS FOR KEY AND MOUSE PRESS ON CANVASES
    #-----------------------------------------------------------------------------------------------

    def onKeyPressOnCanvas1(self, event):
        
        motherCells = [ QtCore.Qt.Key_1, QtCore.Qt.Key_4, QtCore.Qt.Key_B ]
        daughterCells = [ QtCore.Qt.Key_A, QtCore.Qt.Key_P ]

        # find the position of the cursor relative to the image in pixel
        imgshape = self.stacks[self.currentChannel][self.sl.value()].shape
        canshape = self.canvas1.size()
        cf = imgshape[0]/canshape.width()
        refpos = self.canvas1.mapFromGlobal(QtGui.QCursor.pos())
        refpos = np.array([ int( refpos.x() * cf ), int( refpos.y() * cf )])
        refpos = np.append(refpos,self.sl.value())

        ### find the closest cell to the cursor
        idx = closer_cell( refpos.astype( np.uint16 ), self.currentCells )

        ### assign the name to the cell
        if any( [ event.key() == cn for cn in motherCells ] ):
            # if labeling bckg, add the 1 or 2 to the name
            if self.currentCells.ix[ idx, 'cname' ] == 'b_':
                self.currentCells.ix[ idx, 'cname' ] += QtGui.QKeySequence(event.key()).toString().lower()
            else:
                # if not, rename the cell from scratch
                if event.key() == QtCore.Qt.Key_B:
                    self.currentCells.ix[ idx, 'cname' ] = QtGui.QKeySequence(event.key()).toString().lower() + '_'
                else:
                    self.currentCells.ix[ idx, 'cname' ] = QtGui.QKeySequence(event.key()).toString().lower() + '.'

        # add the anterior/posterior to the cell name
        elif any( [ event.key() == cp for cp in daughterCells ] ):
            # don't do it if labeling background (bckg doesn't have a/p!)
            if self.currentCells.ix[ idx, 'cname' ] == 'b_':
                return
            else:
                self.currentCells.ix[ idx, 'cname' ] += QtGui.QKeySequence(event.key()).toString().lower()
        
        # remove the last entry of the name with backspace                
        elif event.key() == QtCore.Qt.Key_Backspace:
            self.currentCells.ix[ idx, 'cname' ] = self.currentCells.ix[ idx, 'cname' ][:-1]
开发者ID:nicolagritti,项目名称:ACVU_project,代码行数:69,代码来源:04markCells.py

示例12: FilterDesignDialog

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
class FilterDesignDialog(QtGui.QDialog):
    """A dialog to apply Takanami's AR picking method to a selected piece of a
    seismic signal.

    Attributes:
        document: Current opened document containing a seismic record.
        seismic_event: A seismic event to be refined by using Takanami method.
            If no event is provided, then a new seismic event will be created
            by using the estimated arrival time after clicking on 'Accept'
    """

    def __init__(self, stream, trace_list=None, parent=None):
        super(FilterDesignDialog, self).__init__(parent)

        # Calc max. frequency
        traces = stream.traces if not trace_list else trace_list
        self.max_freq = max([trace.fs for trace in traces])

        self._init_ui()
        self.load_settings()
        # Initial draw
        w, h_db, angles = self._retrieve_filter_plot_data()
        self._module_data = self.module_axes.plot(w, h_db, 'b')[0]
        self._phase_data = self.phase_axes.plot(w, angles, 'g')[0]
        self.module_axes.set_ylim([-60,10])
        self.phase_axes.set_ylim([min(angles), max(angles)])
        self.canvas.draw_idle()

        self.start_point_spinbox.valueChanged.connect(self.on_freq_min_changed)
        self.end_point_spinbox.valueChanged.connect(self.on_freq_max_changed)
        self.start_point_spinbox.valueChanged.connect(self._draw_filter_response)
        self.end_point_spinbox.valueChanged.connect(self._draw_filter_response)
        self.number_coefficient_spinbox.valueChanged.connect(self._draw_filter_response)
        self.zeroPhaseCheckBox.toggled.connect(self._draw_filter_response)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        self.button_box.clicked.connect(self.on_click)

    def _init_ui(self):
        self.setWindowTitle("Filter Design (Butterworth-Bandpass Filter)")
        self.fig, _ = plt.subplots(1, 1, sharex=True)
        # Set up filter axes
        self.module_axes = self.fig.axes[0]
        self.phase_axes = self.module_axes.twinx()
        self.module_axes.set_title('Digital filter frequency response (Butterworth-Bandpass filter)')
        self.module_axes.set_xlabel('Frequency [Hz]')
        self.module_axes.set_ylabel('Amplitude [dB]', color='b')
        self.module_axes.axis('tight')
        self.module_axes.grid(which='both', axis='both')
        self.phase_axes.set_ylabel('Angle (radians)', color='g')
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setMinimumSize(self.canvas.size())
        self.canvas.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Expanding,
                                                    QtGui.QSizePolicy.Policy.Expanding))
        self.toolBarNavigation = navigationtoolbar.NavigationToolBar(self.canvas, self)
        self.group_box = QtGui.QGroupBox(self)
        self.group_box2 = QtGui.QGroupBox(self)
        self.group_box3 = QtGui.QGroupBox(self)
        self.group_box4 = QtGui.QGroupBox(self)
        self.group_box.setTitle("")
        self.group_box2.setTitle("")
        self.group_box3.setTitle("Parameters")
        self.start_point_label = QtGui.QLabel("Lower cutoff frequency (Hz): ")
        self.start_point_label.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
                                                               QtGui.QSizePolicy.Policy.Preferred))

        self.start_point_spinbox = QtGui.QDoubleSpinBox(self.group_box)
        self.start_point_spinbox.setMinimum(1.0)
        self.start_point_spinbox.setSingleStep(1.00)
        self.start_point_spinbox.setAccelerated(True)
        self.start_point_spinbox.setMaximum(self.max_freq * 0.5)
        self.end_point_label = QtGui.QLabel("Higher cutoff frequency (Hz):")
        self.end_point_label.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
                                                               QtGui.QSizePolicy.Policy.Preferred))
        self.end_point_spinbox = QtGui.QDoubleSpinBox(self.group_box4)
        self.end_point_spinbox.setMinimum(1.0)
        self.end_point_spinbox.setSingleStep(1.00)
        self.end_point_spinbox.setAccelerated(True)
        self.end_point_spinbox.setMaximum(self.max_freq * 0.5)
        self.end_point_spinbox.setValue(5.0)
        #######################################################################

        self.number_coefficient_label = QtGui.QLabel("Order: ")
        self.number_coefficient_label2 = QtGui.QLabel("")
        self.number_coefficient_label.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
                                                               QtGui.QSizePolicy.Policy.Preferred))
        self.number_coefficient_label2.setSizePolicy(QtGui.QSizePolicy(QtGui.QSizePolicy.Policy.Maximum,
                                                               QtGui.QSizePolicy.Policy.Preferred))
        self.number_coefficient_spinbox = QtGui.QSpinBox(self.group_box3)
        self.number_coefficient_spinbox.adjustSize()
        self.number_coefficient_spinbox.setMinimum(1)
        self.number_coefficient_spinbox.setSingleStep(1)
        self.number_coefficient_spinbox.setAccelerated(True)
        self.zeroPhaseCheckBox = QtGui.QCheckBox("Zero phase filtering", self.group_box2)
        self.zeroPhaseCheckBox.setChecked(True)

        #######################################################################

        self.group_box_layout = QtGui.QHBoxLayout(self.group_box)
        self.group_box_layout.setContentsMargins(9, 9, 9, 9)
#.........这里部分代码省略.........
开发者ID:cageo,项目名称:Romero-2016,代码行数:103,代码来源:FilterDesing.py

示例13: GUI

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
class GUI(QtGui.QDialog):
    def __init__(self):
        super(GUI, self).__init__()
        # Pola pomocnicze do obsługi pętli
        self._generator = None
        self._timerId = None
        
        # Właściwe pola klasy
        self.serial = serial.Serial()
        self.data = np.array([[], [], []])
        self.frames = 0;
        self.last_frame = 0;
        self.frames_lost = 0;
        self.window = 100  # Szerokość okna rysowanego sygnału
        
        # Ustawienia ramki
        self.frame_length = 30;  # Długość ramki z danymi
        self.frame_markers = np.array([int('A5', 16), int('5a', 16)])
        self.buffer = bytearray(self.frame_length - len(self.frame_markers))
        
        # Elementy okna
        self.figure = plt.figure()
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setMinimumSize(self.canvas.size())
                                   
        self.serial_line = QtGui.QLineEdit(self)
        self.serial_line.setText('COM9')
        self.serial_line.setAlignment(QtCore.Qt.AlignCenter)
        self.serial_line.setMaxLength(30)
        
        self.serial_line_label = QtGui.QLabel("Port")
        self.serial_line_label.setAlignment(QtCore.Qt.AlignCenter)
        
        self.lost_frames_count = QtGui.QLineEdit(self)
        self.lost_frames_count.setText('0%')
        self.lost_frames_count.setAlignment(QtCore.Qt.AlignCenter)
        self.lost_frames_count.setMaxLength(30)
        
        self.lost_frames_label = QtGui.QLabel("Frames lost")
        self.lost_frames_label.setAlignment(QtCore.Qt.AlignCenter)
        
        self.start_button = self.createButton("Start", self.start)
        self.stop_button = self.createButton("Stop", self.stop)
        self.stop_button.setEnabled(False)
        
        self.info_line = QtGui.QLineEdit(self)
        self.info_line.setReadOnly(True)
        self.info_line.setAlignment(QtCore.Qt.AlignCenter)
        self.info_line.setMaxLength(30)
        self.info_line.setText('INFO')
        
        self.setWindowTitle('Signal Reader v.1.0')
        # Układanie layout'u
        layout = QtGui.QGridLayout()
        layout.setSizeConstraint(QtGui.QLayout.SetFixedSize)
        layout
        layout.addWidget(self.canvas, 0, 0, 1, 2)
        layout.addWidget(self.serial_line_label, 1, 0, 1, 2)
        layout.addWidget(self.serial_line, 2, 0, 1, 2)
        layout.addWidget(self.start_button, 3, 0, 1, 1)
        layout.addWidget(self.stop_button, 3, 1, 1, 1)
        layout.addWidget(self.lost_frames_label, 4, 0, 1, 2)
        layout.addWidget(self.lost_frames_count, 5, 0, 1, 2)
        layout.addWidget(self.info_line, 6, 0, 1, 2)
        self.setLayout(layout)
        self.setFigures()
    
    def setFigures(self):
        self.channel1 = self.figure.add_subplot(3, 1, 1)
        self.channel1.hold(True)
        self.channel1_data, = self.channel1.plot(np.zeros(self.window))
        plt.ylim([0, 4096])
        plt.title('Channel 1')
        plt.grid()
        plt.tight_layout(pad = 0.4, w_pad = 0.5, h_pad = 1.0)
        
        self.channel2 = self.figure.add_subplot(3, 1, 2)
        self.channel2.hold(True)
        self.channel2_data, = self.channel2.plot(np.zeros(self.window))
        plt.ylim([0, 4096])
        plt.title('Channel 2')
        plt.grid()
        plt.tight_layout(pad = 0.4, w_pad = 0.5, h_pad = 1.0)
        
        self.channel3 = self.figure.add_subplot(3, 1, 3)
        self.channel3.hold(True)
        self.channel3_data, = self.channel3.plot(np.zeros(self.window))
        plt.ylim([0, 4096])
        plt.title('Channel 3')
        plt.grid()
        plt.tight_layout(pad = 0.4, w_pad = 0.5, h_pad = 1.0)
        
        plt.ion()
        
    def start(self):
        # Aktywancja/deazktywacja przycisków
        self.start_button.setEnabled(False)
        self.stop_button.setEnabled(True)
        self.port = str(self.serial_line.text())  # Zapisuje nazwę portu
        if self._timerId is not None:
#.........这里部分代码省略.........
开发者ID:mlembke,项目名称:SignalReader,代码行数:103,代码来源:SignalReader.py

示例14: __init__

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]
    def __init__(self, parent=None): #========================================
        super(ImageViewer, self).__init__(parent)
        
        self.scaleFactor = 0
        self.scaleStep = 1.2
        self.pan = False
        
        #---- image container Set Up ----
        
        self.imageLabel = QtGui.QLabel()
        self.imageLabel.setBackgroundRole(QtGui.QPalette.Base)
        self.imageLabel.setSizePolicy(QtGui.QSizePolicy.Ignored,
                                      QtGui.QSizePolicy.Ignored)
        self.imageLabel.setScaledContents(True)
        self.imageLabel.installEventFilter(self)
        
        self.imageLabel.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Raised)
        self.imageLabel.setLineWidth(2)
        self.imageLabel.setMidLineWidth(1)        
        
        #---- Scroll Area Set Up ----
        
        self.scrollArea = QtGui.QScrollArea(self)
        self.scrollArea.setWidget(self.imageLabel)
        self.scrollArea.setAlignment(QtCore.Qt.AlignCenter)
                
        #---- Grid Set Up ----
                
        grid = QtGui.QGridLayout()
               
        grid.addWidget(self.scrollArea, 0, 0)
                
        grid.setSpacing(10)
        grid.setContentsMargins(0, 0, 0, 0) # (Left,Top, Right, Bottom)
        
        self.setLayout(grid)
        self.setWindowTitle("Image Viewer")
              
        #---- Create Initial Image with Matplotlib ----
        
        # http://stackoverflow.com/questions/17676373/
        # python-matplotlib-pyqt-copy-image-to-clipboard
        
        # http://stackoverflow.com/questions/21939658/
        # matplotlib-render-into-buffer-access-pixel-data
        
        figure = plt.figure()
        figure.patch.set_facecolor('white')

        figure_canvas = FigureCanvasQTAgg(figure)
        figure_canvas.draw()
                
        size = figure_canvas.size()
        width, height = size.width(), size.height()
        
        imgbuffer = figure_canvas.buffer_rgba()
        image = QtGui.QImage(imgbuffer, width, height,
                             QtGui.QImage.Format_ARGB32)
                             
        # Reference for the RGB to BGR swap:
        # http://sourceforge.net/p/matplotlib/mailman/message/5194542/
          
        image = QtGui.QImage.rgbSwapped(image)
        
        self.load_image(image, 0)
开发者ID:jpdrolet19,项目名称:WHAT,代码行数:67,代码来源:mplFigViewer.py

示例15: GUI

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import size [as 别名]

#.........这里部分代码省略.........
    # DEFAULT FUNCTION FOR KEY AND MOUSE PRESS ON WINDOW
    #-----------------------------------------------------------------------------------------------

    def wheelEvent(self,event):

        if self.canvas1.underMouse():
            step = event.step
        
        else:          
            step = event.delta()/abs(event.delta())

        ### update daytaframe with previously labeled cells
        newapdvDF = update_apdv_pos_DF( self.currentPos, self.apdvPosDF, self.tp.value() )
        self.apdvPosDF = newapdvDF
        print(self.currentPos) # print previously labeled positions

        ### extract current cells already labeled
        self.currentPos = extract_current_apdv_pos( self.apdvPosDF, self.tp.value() + step )

        self.tp.setValue( self.tp.value() + step ) 

        self.fName.setText( self.timesDF.ix[ self.timesDF.tidxRel == self.tp.value(), 'fName' ].values[0] )

    #-----------------------------------------------------------------------------------------------
    # ADDITIONAL FUNCTIONS FOR KEY AND MOUSE PRESS ON CANVASES
    #-----------------------------------------------------------------------------------------------

    def onKeyPressOnCanvas1(self, event):
        
        posNameList = [ QtCore.Qt.Key_A, QtCore.Qt.Key_P, QtCore.Qt.Key_D ]

        # find the position of the cursor relative to the image in pixel
        imgshape = self.channels[self.currentChannel][0].shape
        canshape = self.canvas1.size()
        cf = imgshape[0]/canshape.width()
        refpos = self.canvas1.mapFromGlobal(QtGui.QCursor.pos())
        refpos = np.array([ int( refpos.x() * cf ), int( refpos.y() * cf )]) * self.compression

        ### find the closest cell to the cursor
        idx = closer_2Dpos( refpos.astype( np.uint16 ), self.currentPos )

        ### assign the name to the cell
        if any( [ event.key() == cn for cn in posNameList ] ):

            self.currentPos.ix[ idx, 'pname' ] = QtGui.QKeySequence(event.key()).toString().lower()

        self.updateCanvas1()
        self.setFocus()

    def onMouseClickOnCanvas1(self, event):
        
        refpos = np.array( [ event.xdata, event.ydata ] ) * self.compression 

        if event.button == 1:

            # create an empty cell in the currentCells df: the only entries are tidx, xyzpos and cname
            newpos = create_single_apdv_pos( refpos.astype(np.uint16), self.tp.value() )
            self.currentPos = pd.concat( [ self.currentPos, newpos ] )
            
        elif event.button == 3:

            # remove a cell (the closest to the cursor at the moment of right-click)
            idx = closer_2Dpos( refpos.astype(np.uint16), self.currentPos )
            self.currentPos = self.currentPos.drop( [ idx ] )

        self.currentPos = self.currentPos.reset_index(drop=True)
开发者ID:nicolagritti,项目名称:ACVU_project,代码行数:70,代码来源:08markAP_DV.py


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