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


Python FigureCanvasQTAgg.flush_events方法代码示例

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


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

示例1: MinionTraceUi

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

#.........这里部分代码省略.........
            self.tracey2 = np.ndarray([0])  # apd2
            self.traceysum = np.ndarray([0])
            self.tracefigure.clear()
            self.traceaxes = self.tracefigure.add_subplot(111)
            self.line1, = self.traceaxes.plot(self.tracex, self.tracey1, '.')
            self.line2, = self.traceaxes.plot(self.tracex, self.tracey2, '.')
            self.line3, = self.traceaxes.plot(self.tracex, self.traceysum, '.')

            self.traceaxes.set_autoscaley_on(True)
            self.tracefigure.canvas.draw()
            self.traceaxes.grid()

            self.traceaquisition = MinionTraceAquisition(self.counttime, self.updatetime, self.parent.fpga)
            self.tracethread = QThread(self, objectName='TraceThread')
            self.traceaquisition.moveToThread(self.tracethread)
            self.traceaquisition.tracestop.connect(self.tracethread.quit)

            self.tracethread.started.connect(self.traceaquisition.longrun)
            self.tracethread.finished.connect(self.tracethread.deleteLater)
            self.traceaquisition.updatetrace.connect(self.updatetraceplot)
            self.tracethread.start()
            self.checkboxupdate()

    def tracestopclicked(self):
        try:
            print('stop trace')
            self.traceaquisition.stop()
            self.tracethread.quit()
        except:
            print('no trace running')

    def updatetracesetting(self):
        self.tracemin = np.round(self.tracemintext.value(), decimals=2)
        self.tracemax = np.round(self.tracemaxtext.value(), decimals=2)
        self.tracelength = np.round(self.tracelengthtext.value(), decimals=2)
        self.updatetraceplot([], [], [], 1)

    @pyqtSlot(np.ndarray, np.ndarray, np.ndarray)
    def updatetraceplot(self, newx, newy1, newy2, updateflag=0):  # if updateflag=1 update min max - only after aquisition possible
        if updateflag == 0:  # TODO - simplify trace plot selection
            self.tracex = np.append(self.tracex, newx)
            self.tracey1 = np.append(self.tracey1, newy1)
            self.tracey2 = np.append(self.tracey2, newy2)
            self.traceysum = self.tracey1+self.tracey2

            self.line1.set_xdata(self.tracex)
            self.line1.set_ydata(self.tracey1)
            self.line2.set_xdata(self.tracex)
            self.line2.set_ydata(self.tracey2)
            self.line3.set_xdata(self.tracex)
            self.line3.set_ydata(self.traceysum)

            tracexminlim = self.tracex.max()-self.tracelength
            if tracexminlim < 0:
                tracexminlim = 0
            self.traceaxes.set_xlim(tracexminlim, self.tracex.max())

            if self.traceapdsumcheck.isChecked() and not self.traceapd1check.isChecked() and not self.traceapd2check.isChecked():
                self.traceaxes.set_ylim(self.traceysum.min(), self.traceysum.max())
            elif self.traceapd1check.isChecked() and not self.traceapd2check.isChecked() and not self.traceapdsumcheck.isChecked():
                self.traceaxes.set_ylim(self.tracey1.min(), self.tracey1.max())
            elif self.traceapd2check.isChecked() and not self.traceapd1check.isChecked() and not self.traceapdsumcheck.isChecked():
                self.traceaxes.set_ylim(self.tracey2.min(), self.tracey2.max())
            elif self.traceapd1check.isChecked() and not self.traceapd2check.isChecked() and self.traceapdsumcheck.isChecked():
                self.traceaxes.set_ylim(np.min([self.tracey1.min(), self.traceysum.min()]), np.max([self.tracey1.max(), self.traceysum.max()]))
            elif self.traceapd2check.isChecked() and not self.traceapd1check.isChecked() and self.traceapdsumcheck.isChecked():
                self.traceaxes.set_ylim(np.min([self.tracey2.min(), self.traceysum.min()]), np.max([self.tracey2.max(), self.traceysum.max()]))
            elif self.traceapd1check.isChecked() and self.traceapd2check.isChecked() and self.traceapdsumcheck.isChecked():
                self.traceaxes.set_ylim(np.min([self.tracey2.min(), self.tracey1.min(), self.traceysum.min()]), np.max([self.tracey2.max(), self.tracey1.max(), self.traceysum.max()]))
            elif self.traceapd1check.isChecked() and self.traceapd2check.isChecked() and not self.traceapdsumcheck.isChecked():
                self.traceaxes.set_ylim(np.min([self.tracey1.min(), self.tracey2.min()]), np.max([self.tracey1.max(), self.tracey2.max()]))

            self.traceaxes.relim()
            self.traceaxes.autoscale_view()
            self.tracecanvas.draw()
            self.tracecanvas.flush_events()

        elif updateflag == 1:
            if len(self.tracex) > 0:
                self.traceaxes.set_xlim(self.tracemin, self.tracemax)
                if self.traceapdsumcheck.isChecked() and not self.traceapd1check.isChecked() and not self.traceapd2check.isChecked():
                    self.traceaxes.set_ylim(self.traceysum.min(), self.traceysum.max())
                elif self.traceapd1check.isChecked() and not self.traceapd2check.isChecked() and not self.traceapdsumcheck.isChecked():
                    self.traceaxes.set_ylim(self.tracey1.min(), self.tracey1.max())
                elif self.traceapd2check.isChecked() and not self.traceapd1check.isChecked() and not self.traceapdsumcheck.isChecked():
                    self.traceaxes.set_ylim(self.tracey2.min(), self.tracey2.max())
                elif self.traceapd1check.isChecked() and not self.traceapd2check.isChecked() and self.traceapdsumcheck.isChecked():
                    self.traceaxes.set_ylim(np.min([self.tracey1.min(), self.traceysum.min()]), np.max([self.tracey1.max(), self.traceysum.max()]))
                elif self.traceapd2check.isChecked() and not self.traceapd1check.isChecked() and self.traceapdsumcheck.isChecked():
                    self.traceaxes.set_ylim(np.min([self.tracey2.min(), self.traceysum.min()]), np.max([self.tracey2.max(), self.traceysum.max()]))
                elif self.traceapd1check.isChecked() and self.traceapd2check.isChecked() and self.traceapdsumcheck.isChecked():
                    self.traceaxes.set_ylim(np.min([self.tracey2.min(), self.tracey1.min(), self.traceysum.min()]), np.max([self.tracey2.max(), self.tracey1.max(), self.traceysum.max()]))
                elif self.traceapd1check.isChecked() and self.traceapd2check.isChecked() and not self.traceapdsumcheck.isChecked():
                    self.traceaxes.set_ylim(np.min([self.tracey1.min(), self.tracey2.min()]), np.max([self.tracey1.max(), self.tracey2.max()]))

                self.traceaxes.relim()
                self.traceaxes.autoscale_view()

                self.tracecanvas.draw()
                self.tracecanvas.flush_events()
开发者ID:erikwiedemann,项目名称:minion-1,代码行数:104,代码来源:minion_trace.py

示例2: subWindow

# 需要导入模块: from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt5agg.FigureCanvasQTAgg import flush_events [as 别名]
class subWindow(QMainWindow):
    
    #set up a signal so that the window closes when the main window closes
    #closeWindow = QtCore.pyqtSignal()
    
    #replot = pyqtsignal()
    
    def __init__(self,parent=None):
        super(QMainWindow, self).__init__(parent)
        self.parent=parent
        
        self.effExpTime = .010  #units are s
        
        self.create_main_frame()
        self.activePixel = parent.activePixel
        self.parent.updateActivePix.connect(self.setActivePixel)
        self.a = parent.a
        self.spinbox_startTime = parent.spinbox_startTime
        self.spinbox_integrationTime = parent.spinbox_integrationTime
        self.spinbox_startLambda = parent.spinbox_startLambda
        self.spinbox_stopLambda = parent.spinbox_stopLambda
        self.image = parent.image
        self.beamFlagMask = parent.beamFlagMask
        self.apertureRadius = 2.27/2   #Taken from Seth's paper (not yet published in Jan 2018)
        self.apertureOn = False
        self.lineColor = 'blue'
        

    def getAxes(self):
        return self.ax
        
    def create_main_frame(self):
        """
        Makes GUI elements on the window
        """
        self.main_frame = QWidget()
        
        # Figure
        self.dpi = 100
        self.fig = Figure((3.0, 2.0), dpi=self.dpi, tight_layout=True)
        self.canvas = FigureCanvas(self.fig)
        self.canvas.setParent(self.main_frame)
        self.ax = self.fig.add_subplot(111)
        
        #create a navigation toolbar for the plot window
        self.toolbar = NavigationToolbar(self.canvas, self)
        
        #create a vertical box for the plot to go in.
        vbox_plot = QVBoxLayout()
        vbox_plot.addWidget(self.canvas)
        
        #check if we need effective exposure time controls in the window, and add them if we do. 
        try:
            self.spinbox_effExpTime
        except:
            pass
        else:
            label_expTime = QLabel('effective exposure time [ms]')
            button_plot = QPushButton("Plot")
            
            hbox_expTimeControl = QHBoxLayout()
            hbox_expTimeControl.addWidget(label_expTime)
            hbox_expTimeControl.addWidget(self.spinbox_effExpTime)
            hbox_expTimeControl.addWidget(button_plot)
            vbox_plot.addLayout(hbox_expTimeControl)
            
            self.spinbox_effExpTime.setMinimum(1)
            self.spinbox_effExpTime.setMaximum(200)
            self.spinbox_effExpTime.setValue(1000*self.effExpTime)
            button_plot.clicked.connect(self.plotData)
            
        vbox_plot.addWidget(self.toolbar)

        
        #combine everything into another vbox
        vbox_combined = QVBoxLayout()
        vbox_combined.addLayout(vbox_plot)
        
        #Set the main_frame's layout to be vbox_combined
        self.main_frame.setLayout(vbox_combined)

        #Set the overall QWidget to have the layout of the main_frame.
        self.setCentralWidget(self.main_frame)
                
        
    def draw(self):
        #The plot window calls this function
        self.canvas.draw()
        self.canvas.flush_events()     
        
        
    def setActivePixel(self):
        self.activePixel = self.parent.activePixel
#        if self.parent.image[self.activePixel[0],self.activePixel[1]] ==0: #only plot data from good pixels
#            self.lineColor = 'red'
#        else:
#            self.lineColor = 'blue'
        try:
            self.plotData() #put this in a try statement in case it doesn't work. This way it won't kill the whole gui. 
        except:
#.........这里部分代码省略.........
开发者ID:srmeeker,项目名称:DarknessPipeline,代码行数:103,代码来源:quickLook.py

示例3: mainWindow

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

#.........这里部分代码省略.........

        
        #Now create another vbox, and add the plot vbox and the button's hbox to the new vbox.
        vbox_combined = QVBoxLayout()
        vbox_combined.addLayout(vbox_plot)
        vbox_combined.addLayout(hbox_controls)
        vbox_combined.addLayout(vbox_filenames)
        
        #Set the main_frame's layout to be vbox_combined
        self.main_frame.setLayout(vbox_combined)

        #Set the overall QWidget to have the layout of the main_frame.
        self.setCentralWidget(self.main_frame)
        
        #set up the pyqt5 events
        cid = self.fig.canvas.mpl_connect('motion_notify_event', self.hoverCanvas)
        cid2 = self.fig.canvas.mpl_connect('button_press_event', self.mousePressed)
        cid3 = self.fig.canvas.mpl_connect('scroll_event', self.scroll_ColorBar)
        

        
        
    def quickLoadH5(self):
        self.filename = '/Users/clint/Documents/mazinlab/ScienceData/PAL2017b/20171004/1507175503.h5'
        self.loadDataFromH5()  
        


        
        
    def draw(self):
        #The plot window calls this function
        self.canvas.draw()
        self.canvas.flush_events()
        
        
    def hoverCanvas(self,event):
        if event.inaxes is self.ax1:
            col = int(round(event.xdata))
            row = int(round(event.ydata))
            if row < self.nRow and col < self.nCol:
                self.status_text.setText('({:d},{:d}) {}'.format(col,row,self.image[row,col]))
                
                
    def scroll_ColorBar(self,event):
        if event.inaxes is self.fig.cbar.ax:
            stepSize = 0.1  #fractional change in the colorbar scale
            if event.button == 'up':
                self.cbarLimits[1] *= (1 + stepSize)   #increment by step size
                self.fig.cbar.set_clim(self.cbarLimits[0],self.cbarLimits[1])
                self.fig.cbar.draw_all()
                self.ax1.imshow(self.image,interpolation='none',vmin = self.cbarLimits[0],vmax = self.cbarLimits[1])
            elif event.button == 'down':
                self.cbarLimits[1] *= (1 - stepSize)   #increment by step size
                self.fig.cbar.set_clim(self.cbarLimits[0],self.cbarLimits[1])
                self.fig.cbar.draw_all()
                self.ax1.imshow(self.image,interpolation='none',vmin = self.cbarLimits[0],vmax = self.cbarLimits[1])
                
            else:
                pass
                
        self.draw()
        
        
                
                
开发者ID:srmeeker,项目名称:DarknessPipeline,代码行数:66,代码来源:quickLook.py

示例4: mainWindow

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

#.........这里部分代码省略.........
        vbox_combined.addWidget(self.label_log_path)
        
        #Set the main_frame's layout to be vbox_combined
        self.main_frame.setLayout(vbox_combined)

        #Set the overall QWidget to have the layout of the main_frame.
        self.setCentralWidget(self.main_frame)
        
        #set up the pyqt5 events
        cid = self.fig.canvas.mpl_connect('motion_notify_event', self.hoverCanvas)
        cid3 = self.fig.canvas.mpl_connect('scroll_event', self.scroll_ColorBar)
        

        
        
    def spinBoxValueChange(self):     
        try:
            filename = self.fileListRaw[np.where(self.timeStampList==self.spinbox_imgTimestamp.value())[0][0]]
        except:
            self.plotBlank()
            self.updateLogLabel(IMG_fileExists = False)
        else:
            self.plotImage(filename)
            self.updateLogLabel()
            
        


        
        
    def draw(self):
        #The plot window calls this function
        self.canvas.draw()
        self.canvas.flush_events()
        
        
    def hoverCanvas(self,event):
        if event.inaxes is self.ax1:
            col = int(round(event.xdata))
            row = int(round(event.ydata))
            if row < self.nRow and col < self.nCol:
                self.status_text.setText('({:d},{:d}) {}'.format(col,row,self.image[row,col]))
                
                
    def scroll_ColorBar(self,event):
        if event.inaxes is self.fig.cbar.ax:
            stepSize = 0.1  #fractional change in the colorbar scale
            if event.button == 'up':
                self.cbarLimits[1] *= (1 + stepSize)   #increment by step size
                self.fig.cbar.set_clim(self.cbarLimits[0],self.cbarLimits[1])
                self.fig.cbar.draw_all()
                self.ax1.imshow(self.image,interpolation='none',vmin = self.cbarLimits[0],vmax = self.cbarLimits[1])
            elif event.button == 'down':
                self.cbarLimits[1] *= (1 - stepSize)   #increment by step size
                self.fig.cbar.set_clim(self.cbarLimits[0],self.cbarLimits[1])
                self.fig.cbar.draw_all()
                self.ax1.imshow(self.image,interpolation='none',vmin = self.cbarLimits[0],vmax = self.cbarLimits[1])
                
            else:
                pass
                
        self.draw()
        
        

开发者ID:srmeeker,项目名称:DarknessPipeline,代码行数:66,代码来源:quickLook_img.py


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