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


Python FigureCanvasQTAgg.flush_events方法代码示例

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


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

示例1: MplWidget

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import flush_events [as 别名]
class MplWidget(QtGui.QWidget):
    def __init__(self, parent=None):
        super(MplWidget, self).__init__(parent)

        self.figure = Figure()
        
        self.ax = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self.figure)
        self.toolbar = NavigationToolbar(self.canvas, self)
        
        layout = QtGui.QVBoxLayout()
        layout.addWidget(self.toolbar)
        layout.addWidget(self.canvas)
        self.setLayout(layout)
        
        self.cb = None
        self.im = None
        self.imsz = None
        
    def imshow(self, img):
        if self.im:
            self.imsz = self.im.get_size()
            newsz = img.shape
            self.im.set_data(img)
            if self.imsz[0] != newsz[0] or self.imsz[1] != newsz[1]:    # update extent
                self.im.set_extent((-0.5, newsz[1]-0.5, newsz[0]-0.5, -0.5))            
        else:
            self.im = self.ax.imshow(img,interpolation='none')
        
        if self.cb:
            self.im.autoscale()
        else:
            self.cb = self.figure.colorbar(self.im)
            
        report_pixel = lambda x, y : "(%6.3f, %6.3f) %.3f" % (x,y, img[np.floor(y+0.5),np.floor(x+0.5)])
        self.ax.format_coord = report_pixel
            
        self.canvas.draw()
        self.canvas.flush_events()
开发者ID:Dangzheng,项目名称:Stereo,代码行数:41,代码来源:flowtools.py

示例2: RoachPhaseStreamWindow

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

#.........这里部分代码省略.........
        button_snapPhase.clicked.connect(self.phaseSnapShot)
        
        
        numSnapsThresh = self.config.getint('Roach '+str(self.roachNum),'numsnaps_thresh')
        spinbox_numSnapsThresh = QSpinBox()
        spinbox_numSnapsThresh.setValue(numSnapsThresh)
        spinbox_numSnapsThresh.setRange(1,100)
        spinbox_numSnapsThresh.setSuffix(" *2 msec")
        spinbox_numSnapsThresh.setWrapping(False)
        spinbox_numSnapsThresh.setButtonSymbols(QAbstractSpinBox.NoButtons)
        spinbox_numSnapsThresh.setCorrectionMode(QAbstractSpinBox.CorrectToNearestValue)
        spinbox_numSnapsThresh.valueChanged.connect(partial(self.changedSetting,'numsnaps_thresh'))
        
        threshSigs = self.config.getfloat('Roach '+str(self.roachNum),'numsigs_thresh')
        spinbox_threshSigs = QDoubleSpinBox()
        spinbox_threshSigs.setValue(threshSigs)
        spinbox_threshSigs.setRange(0,100)
        spinbox_threshSigs.setSuffix(" sigmas")
        spinbox_threshSigs.setWrapping(False)
        spinbox_threshSigs.setButtonSymbols(QAbstractSpinBox.NoButtons)
        spinbox_threshSigs.setCorrectionMode(QAbstractSpinBox.CorrectToNearestValue)
        spinbox_threshSigs.valueChanged.connect(partial(self.changedSetting,'numsigs_thresh'))
        spinbox_threshSigs.valueChanged.connect(lambda x: self.resetRoach.emit(RoachStateMachine.LOADTHRESHOLD))       # reset state of roach
        
        button_loadThresh = QPushButton("Load Thresholds")
        button_loadThresh.setEnabled(True)
        button_loadThresh.clicked.connect(self.thresholdClicked)
        
        longSnapTime = self.config.getfloat('Roach '+str(self.roachNum),'longsnaptime')
        spinbox_longSnapTime = QDoubleSpinBox()
        spinbox_longSnapTime.setValue(longSnapTime)
        spinbox_longSnapTime.setRange(0,1000)
        spinbox_longSnapTime.setSuffix(" seconds")
        spinbox_longSnapTime.setWrapping(False)
        spinbox_longSnapTime.setButtonSymbols(QAbstractSpinBox.NoButtons)
        spinbox_longSnapTime.setCorrectionMode(QAbstractSpinBox.CorrectToNearestValue)
        spinbox_longSnapTime.valueChanged.connect(partial(self.changedSetting,'longsnaptime'))
        
        button_longSnap = QPushButton("Collect Phase Timestream")
        button_longSnap.setEnabled(True)
        button_longSnap.clicked.connect(self.phaseTimeStream)
        
        vbox_plot = QVBoxLayout()
        vbox_plot.addWidget(self.canvas)
        vbox_plot.addWidget(self.mpl_toolbar)
        
        hbox_ch = QHBoxLayout()
        hbox_ch.addWidget(label_channel)
        hbox_ch.addWidget(self.spinbox_channel)
        hbox_ch.addWidget(self.label_freq)
        hbox_ch.addWidget(self.label_thresh)
        hbox_ch.addWidget(self.label_median)
        hbox_ch.addWidget(button_snapPhase)
        hbox_ch.addStretch()
        
        hbox_thresh = QHBoxLayout()
        hbox_thresh.addWidget(spinbox_numSnapsThresh)
        hbox_thresh.addWidget(spinbox_threshSigs)
        hbox_thresh.addWidget(button_loadThresh)
        hbox_thresh.addStretch()
        
        hbox_phaseTimestream = QHBoxLayout()
        hbox_phaseTimestream.addWidget(spinbox_longSnapTime)
        hbox_phaseTimestream.addWidget(button_longSnap)
        hbox_phaseTimestream.addStretch()
        
        vbox1 = QVBoxLayout()
        vbox1.addLayout(vbox_plot)
        vbox1.addLayout(hbox_ch)
        vbox1.addLayout(hbox_thresh)
        vbox1.addLayout(hbox_phaseTimestream)
        
        self.main_frame.setLayout(vbox1)
        self.setCentralWidget(self.main_frame)
    
    def draw(self):
        #print 'r'+str(self.roachNum)+' drawing data - '+str(self.counter)
        self.canvas.draw()
        self.canvas.flush_events()
    
    def changedSetting(self,settingID,setting):
        """
        When a setting is changed, reflect the change in the config object which is shared across all GUI elements.
        
        INPUTS:
            settingID - the key in the configparser
            setting - the value
        """
        self.config.set('Roach '+str(self.roachNum),settingID,str(setting))
        #If we don't force the setting value to be a string then the configparser has trouble grabbing the value later on for some unknown reason
        newSetting = self.config.get('Roach '+str(self.roachNum),settingID)
        print 'setting ',settingID,' to ',newSetting
    
    def closeEvent(self, event):
        if self._want_to_close:
            event.accept()
            self.close()
        else:
            event.ignore()
            self.hide()
开发者ID:mstrader,项目名称:MkidDigitalReadout,代码行数:104,代码来源:RoachPlotWindow.py

示例3: mpl_widget

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

#.........这里部分代码省略.........
        elif event.key == 'escape':
            self.clear_selection()


    def change_coordinate_formatter(self, ax, data2d,  bruteforce_flag=None, bruteforce_dims=None):
        ''' see http://stackoverflow.com/questions/14754931/matplotlib-values-under-cursor
        '''
        numrows, numcols = data2d.shape
        bruteforce_mode_on = False
        bruteforce_mode_on = (bruteforce_flag == '2DXY' and bruteforce_dims[-1] and bruteforce_dims[-2])


        def format_coord(x, y):
            col = int(x+0.5)
            row = int(y+0.5)

            if not bruteforce_mode_on:
                if col >= 0 and col < numcols and row >= 0 and row < numrows:
                    #z = data2d[row, col]
                    # sice we have artificially reversed y-coordinate axes, now reverse data!
                    # numrows-1, because if nrows=10 => row=[0:9]
                    z = data2d[numrows-1-row, col]
                    #return 'x=%1.1f y=%1.1f z=%1.6f' % (x, y, z)
                    return 'i=%d j=%d z=%.6f' % (col, row, z)
                else:
                    #return 'x=%1.4f, y=%1.4f' % (x, y)
                    return 'outside data area'

            elif bruteforce_flag == '2DXY' and bruteforce_dims[-1] and bruteforce_dims[-2]:
                '''
                our extend in X=[-0.5:numcols-0.5], Y=[-0.5:numrows-0.5], because col,row is cell center!
                '''
                if col >= 0 and col < numcols and row >= 0 and row < numrows:
                    #z = data2d[row, col]
                    # sice we have artificially reversed y-coordinate axes, now reverse data!
                    # numrows-1, because if nrows=10 => row=[0:9]
                    z = data2d[numrows-1-row, col]
                    real_x, real_y = self.get_real_xy(x, y, bruteforce_dims)

                    #return 'x=%1.1f y=%1.1f z=%1.6f' % (x, y, z)
                    #return 'i=%d j=%d z=%.3f x=%.4f y=%.4f' % (col, row, z, real_x, real_y)
                    return 'i=%d j=%d z=%.3f, %s=%.2f %s=%.2f' % (
                        col, row, z, bruteforce_dims[-1], real_x, bruteforce_dims[-2], real_y)
                else:
                    #return 'x=%1.4f, y=%1.4f' % (x, y)
                    return 'outside data area'
            else:
                raise ValueError('bruteforce_flag can be $None$ or $"2DXY"$. Passed %s' % bruteforce_flag)
        ax.format_coord = format_coord


    def allow_menu(self):
        allow = False
        #print "self.mainWidget.get_plotType():", self.mainWidget.get_plotType()
        #print "self.mainWidget.get_plotType_for_timeseries():", self.mainWidget.get_plotType_for_timeseries()
        if self.mainWidget.get_plotType() == "2D" and not self.mainWidget.get_plotType_for_timeseries() == "2DZT":
            allow = True
        return allow
    

    def get_real_xy(self, i, j, dimension_list):
        '''
        functions returns values of x,y based on passed indexes i, j

        '''
        if any(dimension_list[-2:-1]) is None:
            print 'Dimensions X,Y of current variable are not specified (variables that have same name as dimensions not found)'
            raise ValueError('Dimensions X,Y of current variable are not specified (variables that have same name as dimensions not found)')
        nc = self.mainWidget.get_selected_ncfile_instance()
        try:
            x_var = nc.variables[dimension_list[-1]]
            y_var = nc.variables[dimension_list[-2]]
            
        except:
            
            print ('Failed to load variables: {0}, {1}'.format(dimension_list[-1], dimension_list[-2]))
            raise ValueError('Failed to load variables: {0}, {1}'.format(dimension_list[-1], dimension_list[-2]))


        x_ratio = (x_var[-1]-x_var[0])/(len(x_var)-1)
        y_ratio = (y_var[-1]-y_var[0])/(len(y_var)-1)

        #x[i] = x_var[0]+x_ratio*i
        #y[j] = y_var[0]+y_ratio*j
        x = x_var[0] + x_ratio*i
        y = y_var[0] + y_ratio*j
        nc.close()
        return (x, y)

    def get_axes(self):
        return self.fig.get_axes()
    

    def fast_redraw(self, artist):
        background = [self.canvas.copy_from_bbox(self.get_axes()[0].bbox)]
        self.get_axes()[0].draw_artist(artist)
        self.canvas.restore_region(background)
        self.canvas.blit(self.get_axes()[0].bbox)
        self.canvas.update()
        self.canvas.flush_events()
开发者ID:cdd1969,项目名称:ncinfo,代码行数:104,代码来源:my_matplotlib_widget.py

示例4: Main

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

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

		# GPU
		if (values[21] <= 0):
			self.LCD_GPU.setStyleSheet( "color: #C0C0C0;" )
		elif (values[14] >= 60): 
			self.LCD_GPU.setStyleSheet( "color: #FF0000;" )		
		else:
			self.LCD_GPU.setStyleSheet( "color: #000000;" )

		self.LCD_DVFS_MAX.display('%.f' % values[15])
		self.LCD_DVFS_MIN.display('%.f' % values[16])
		self.LCD_GPU_FREQ.display('%.f' % values[13])
		self.LCD_GPU_UTIL.display('%.f' % values[14])
		self.LCD_DDR.display('%.f' % values[17])
		self.LCD_BUS.display('%.f' % values[18])

		self.LCD_APT.display('%.1f\'' % values[22])
		self.LCD_PST.display('%.1f\'' % values[23])	
		self.LCD_CPU_G0.display('%.1f\'' % values[19])
		self.LCD_CPU_G1.display('%.1f\'' % values[20])
		self.LCD_GPU.display('%.1f\'' % values[21])

		self.LCD_CPU0.display('%.f' % values[1])
		self.LCD_CPU1.display('%.f' % values[2])
		self.LCD_CPU2.display('%.f' % values[3])
		self.LCD_CPU3.display('%.f' % values[4])
		self.LCD_CPU4.display('%.f' % values[5])
		self.LCD_CPU5.display('%.f' % values[6])
		self.LCD_CPU6.display('%.f' % values[7])
		self.LCD_CPU7.display('%.f' % values[8])


		# graph
		x = arange(100)
		padd = [None]*(100-loc)
		
		#draw graph, style, color, 
		width = 1.0
		anti = False


		self.ax1[0].plot(x, self.mCPU0[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[1].plot(x, self.mCPU1[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[2].plot(x, self.mCPU2[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[3].plot(x, self.mCPU3[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[4].plot(x, self.mCPU4[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[5].plot(x, self.mCPU5[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[6].plot(x, self.mCPU6[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		self.ax1[7].plot(x, self.mCPU7[-100:] + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti)
		
		#self.ax1[0].axvline(x=loc, ymin=0, ymax=1, color='#006000', linewidth=3)

		self.ax2[0].plot(x, self.mDVFS_Max[-100:] + padd, linestyle='-', color='#FFFF00', linewidth=width, antialiased=anti) # DVFS
		self.ax2[0].plot(x, self.mDVFS_Min[-100:] + padd, linestyle='-', color='#0000FF', linewidth=width, antialiased=anti) # DVFS
		self.ax2[1].plot(x, self.mDDR[-100:]      + padd, linestyle='-', color='#FFFF00', linewidth=width, antialiased=anti) # DDR
		self.ax2[2].plot(x, self.mBUS[-100:]      + padd, linestyle='-', color='#FFFF00', linewidth=width, antialiased=anti) # BUS
		self.ax2[3].plot(x, self.mGPUFreq[-100:]  + padd, linestyle='-', color='#FFFF00', linewidth=width, antialiased=anti) # GPU Freq
		self.ax2[4].plot(x, self.mGPUUtil[-100:]  + padd, linestyle='-', color='#FFFF00', linewidth=width, antialiased=anti) # GPU Util	
		self.ax2[5].plot(x, self.mAPT[-100:]      + padd, linestyle='-', color='#FF0000', linewidth=width, antialiased=anti) # APT
		self.ax2[6].plot(x, self.mPST[-100:]      + padd, linestyle='-', color='#FF0000', linewidth=width, antialiased=anti) # PST		
		self.ax2[7].plot(x, self.mCPUG0[-100:]    + padd, linestyle='-', color='#FF0000', linewidth=width, antialiased=anti) # C0 Temperature
		self.ax2[7].plot(x, self.mCPUG1[-100:]    + padd, linestyle='-', color='#00FF00', linewidth=width, antialiased=anti) # C1 Temperature
		self.ax2[7].plot(x, self.mGPU[-100:]      + padd, linestyle='-', color='#0000FF', linewidth=width, antialiased=anti) # C2 Temperature

		self.canvas1.draw()
		self.canvas2.draw()

		self.canvas1.flush_events()
		self.canvas2.flush_events()
		#self.show()

		self.thread = Timer(self.duration/1000.0, self.update)
		self.thread.start()


		"""ax1 = self.ax1
		x = np.arange(0,100.0)
		y1 = (np.cos(2*np.pi*x/50.0)+1.0) * 1000
		
		#ax1[0].clear()
		ax1[0].plot(x, y1, linestyle='-', color='#00FF00', linewidth=2)
		self.canvas1.draw()
		self.canvas1.flush_events()
		self.show()"""
		
		print ('Update is done')

	def StartButton(self):		
		print ('StartButton')
		Device_Info(self.listWidget)		
		self.duration = 1000
		self.showfreq = ShowFreq(self.duration)
		self.update() 
		self.thread = Timer(0.5, self.update)
		self.thread.start()
		#ani animation.FuncAnimation(fig, animate, interval = 10)

	
	def StopButton(self):
		print ('StopButton')
开发者ID:3WiseMen,项目名称:python,代码行数:104,代码来源:VisualShowfreq.v4.py

示例5: PlotHandler

# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import flush_events [as 别名]
class PlotHandler(object):
    def __init__(self, parent):
        self.figure = Figure(tight_layout=True)
        self.canvas = FigureCanvas(self.figure)
        self.canvas.setContentsMargins(0,0,0,0)
        self.axes = self.figure.add_subplot(111, projection='3d')
        Axes3D.set_autoscale_on(self.axes, True)
        Axes3D.autoscale_view(self.axes)
        self.canvas.setParent(parent)
        self.activePlot = None
        self.activePopulation = None

        self.surface = None
        self.scatter = None

    def get_widget(self):
        return self.canvas

    def updatePlot(self, X, Y, Z, population=None):
        self.activePlot = (X,Y,Z)
        x, y = np.meshgrid(X,Y)

        if self.surface is not None:
            self.surface.remove()

        if self.scatter is not None:
            self.scatter.remove()

        # surface
        self.surface = Axes3D.plot_surface(
                self.axes,
                x, y, Z,
                rstride=1,
                cstride=1,
                cmap=cm.coolwarm,
                linewidth=0,
                antialiased=False,
                shade=False,
                alpha=0.5
        )

        # population
        if population is not None:
            self.activePopulation = population
            x, y, z = self.preparePopulationData(population)
            self.scatter = Axes3D.scatter(self.axes, x, y, z, c="r", marker="o")
            self.scatter.set_alpha(1.0)

        # Draw all
        self.canvas.draw()
        self.canvas.flush_events()

    def updatePopulation(self, population):
        self.activePopulation = population
        x, y, z = self.preparePopulationData(population)

        if self.scatter is not None:
            self.scatter.remove()

        self.scatter = Axes3D.scatter(self.axes, x, y, z, c="r", marker="o")
        # self.surface.set_zorder(2)
        # self.scatter.set_zorder(100)
        self.scatter.set_alpha(1.0)
        self.canvas.draw()
        self.canvas.flush_events()

    def preparePopulationData(self, population):
        x = []
        y = []
        z = []
        for p in population:
            # x.append(p.parameters[0])
            # y.append(p.parameters[1])
            # z.append(p.fitness)
            x.append(p[0])
            y.append(p[1])
            z.append(p[2]+0.1)
        return (x, y, z)
开发者ID:Nialaren,项目名称:bia_project,代码行数:80,代码来源:matplotlibPlotHandler.py

示例6: streamPick

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

#.........这里部分代码省略.........
                <blockquote>
                Use mouse wheel to zoom in- and out. Middle mouse button moves
                plot along x-axis.<br>
                Hit <b>Ctrl</b> to manipulate a single plot.
                <br>
                </blockquote>
                <div>
                Programm stores filter parameters in <code>.pick_filter</code>
                and a backup of recent picks in
                <code>.picks-obspy.xml.bak</code>.<br><br>
                See <a href=http://www.github.org/miili/StreamPick>
                http://www.github.org/miili/StreamPick</a> and
                <a href=http://www.obspy.org>http://www.obspy.org</a>
                for further documentation.
                </div>
                """ % (
                    self._shortcuts['st_next'],
                    self._shortcuts['st_previous'],
                    self._shortcuts['filter_apply'],
                    self._shortcuts['pick_p'],
                    self._shortcuts['pick_s'],
                    self._shortcuts['pick_custom'],
                    self._shortcuts['pick_remove'],
                    )
        QtGui.QMessageBox.about(self, 'About', msg)

    def _canvasDraw(self):
        '''
        Redraws the canvas and re-sets mouse focus
        '''
        for _i, _ax in enumerate(self.fig.get_axes()):
            _ax.set_xticklabels(_ax.get_xticks() * self._current_st[_i].stats.delta)
        self.canvas.draw_idle()
        self.canvas.flush_events()
        self.canvas.setFocus()
        return

    def closeEvent(self, evnt):
        '''
        This function is called upon closing the QtGui
        '''
        # Save Picks
        pickle.dump(self.bpfilter, open('.pick_filters', 'w'))
        # Save Catalog
        if len(self._picks) > 0:
            self._saveCatalog('.picks-obspy.xml.bak')
        if self.savefile is None and len(self._picks) > 0:
            ask = QtGui.QMessageBox.question(self, 'Save Picks?',
                'Do you want to save your picks?',
                QtGui.QMessageBox.Save |
                QtGui.QMessageBox.Discard |
                QtGui.QMessageBox.Cancel, QtGui.QMessageBox.Save)
            if ask == QtGui.QMessageBox.Save:
                self._saveCatalog()
            elif ask == QtGui.QMessageBox.Cancel:
                evnt.ignore()
        print self._picks


    # Filter Dialog
    class defFilter(QtGui.QDialog):
        def __init__(self, parent=None, filtervalues=None):
            '''
            Bandpass filter dialog... Qt layout and stuff
            '''
            QtGui.QDialog.__init__(self, parent)
开发者ID:d-chambers,项目名称:StreamPick,代码行数:70,代码来源:streamPick.py

示例7: mGraph

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

#.........这里部分代码省略.........
                            # mini = min(column)

                            # self.ax.set_ylim(mini-mini/2, maxi+maxi/2)
                            # self.ax.set_xlim(min(times), max(times))
                            # self.ax.draw_artist(self.line[i])
                        except:

                            traceback.print_exc()

                            # print "Failed to log data"
                        # Add a legend
                        legend = self.ax.legend(loc="upper left")
                        self.ax.set_title(
                            self.device.getFrame().getTitle(), color=(189.0 / 255, 195.0 / 255, 199.0 / 255)
                        )

                        if (
                            self.device.getFrame().getYLabel() is not None
                            and len(self.device.getFrame().getCustomUnits()) is not 0
                        ):
                            self.ax.set_ylabel(
                                self.device.getFrame().getYLabel()
                                + " ("
                                + self.device.getFrame().getCustomUnits()
                                + ")"
                            )
                        elif (
                            self.device.getFrame().getYLabel() is not None
                            and len(self.device.getFrame().getUnits()[i - 1]) is not 0
                        ):

                            self.ax.set_ylabel(
                                self.device.getFrame().getYLabel()
                                + " ("
                                + self.device.getFrame().getUnits()[i - 1]
                                + ")"
                            )

                        self.ax.set_xlabel("Time")

                        self.ax.hold(True)
                        # locator = AutoDateLocator()
                        # self.ax.fmt_xdata = AutoDateFormatter()
                        # self.ax.xaxis.set_major_locator(locator)
                        # self.ax.xaxis.set_major_locator(locator)
                        # self.ax.xaxis.set_major_formatter(DateFormatter('%m/%d'))

                        # self.ax.fmt_xdata = mdates.DateFormatter('%m/%d %H:%M:%S')
                        # print "type: ", type(times[-1])
                        # print "time[-1]: ",times[-1]
                        # self.ax.set_ylim(bottom = 733681, top = 733682)

                        # self.figure.tight_layout()
                        self.ax.grid(True)

                except Exception as e:
                    print "Error"
                try:

                    self.ax.grid(True)
                    # self.ax.clear(self.ax.yaxis)
                    # self.ax.cla()

                    if self.home:
                        self.ax.set_xlim(times[0], times[-1])
                        self.ax.relim()
                        self.ax.autoscale()

                    # print self.ax.get_data_interval()
                    self.ax.draw_artist(self.figure)
                    self.ax.draw_artist(self.ax.patch)

                    locator = AutoDateLocator()

                    self.ax.xaxis.set_major_locator(locator)
                    self.ax.xaxis.set_major_formatter(DateFormatter("%m/%d %H:%M:%S"))
                    self.figure.autofmt_xdate()
                    # print [time.toordinal() for time in times]
                    self.ax.draw_artist(self.ax.yaxis)
                    self.ax.draw_artist(self.ax.xaxis)

                    for line in self.line:
                        self.ax.draw_artist(line)

                    # self.ax.axis('off')

                    self.ax.draw_artist(legend)

                    self.canvas.update()

                    self.canvas.flush_events()

                except:
                    times = [datetime.datetime.fromtimestamp(row[0]) for row in data]
                    traceback.print_exc()
                    self.ax.set_xlim(times[0], times[-1])
                    self.ax.relim()
                    self.ax.autoscale()
                    # print self.ax.get_data_interval()
                    pass
开发者ID:McDermott-Group,项目名称:servers,代码行数:104,代码来源:MGrapher.py

示例8: streamPick

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

#.........这里部分代码省略.........
                <blockquote>
                Use mouse wheel to zoom in- and out. Middle mouse button moves
                plot along x-axis.<br>
                Hit <b>Ctrl</b> to manipulate a single plot.
                <br>
                </blockquote>
                <div>
                Programm stores filter parameters in <code>.pick_filter</code>
                and a backup of recent picks in
                <code>.picks-obspy.xml.bak</code>.<br><br>
                See <a href=http://www.github.org/miili/StreamPick>
                http://www.github.org/miili/StreamPick</a> and
                <a href=http://www.obspy.org>http://www.obspy.org</a>
                for further documentation.
                </div>
                """ % (
            self._shortcuts["st_next"],
            self._shortcuts["st_previous"],
            self._shortcuts["filter_apply"],
            self._shortcuts["pick_p"],
            self._shortcuts["pick_s"],
            self._shortcuts["pick_custom"],
            self._shortcuts["pick_remove"],
        )
        QtGui.QMessageBox.about(self, "About", msg)

    def _canvasDraw(self):
        """
        Redraws the canvas and re-sets mouse focus
        """
        for _i, _ax in enumerate(self.fig.get_axes()):
            _ax.set_xticklabels(_ax.get_xticks() * self._current_st[_i].stats.delta)
        self.canvas.draw_idle()
        self.canvas.flush_events()
        self.canvas.setFocus()
        return

    def closeEvent(self, evnt):
        """
        This function is called upon closing the QtGui
        """
        # Save Picks
        pickle.dump(self.bpfilter, open(".pick_filters", "w"))
        # Save Catalog
        if len(self._picks) > 0:
            self._saveCatalog(".picks-obspy.xml.bak")
        if self.savefile is None and len(self._picks) > 0:
            ask = QtGui.QMessageBox.question(
                self,
                "Save Picks?",
                "Do you want to save your picks?",
                QtGui.QMessageBox.Save | QtGui.QMessageBox.Discard | QtGui.QMessageBox.Cancel,
                QtGui.QMessageBox.Save,
            )
            if ask == QtGui.QMessageBox.Save:
                self._saveCatalog()
            elif ask == QtGui.QMessageBox.Cancel:
                evnt.ignore()
        print self._picks

    # Filter Dialog
    class defFilter(QtGui.QDialog):
        def __init__(self, parent=None, filtervalues=None):
            """
            Bandpass filter dialog... Qt layout and stuff
            """
开发者ID:calum-chamberlain,项目名称:StreamPick,代码行数:70,代码来源:streamPick.py


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