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


Python NavigationToolbar2QT.zoom方法代码示例

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


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

示例1: MPL_Widget

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import zoom [as 别名]
class MPL_Widget(QtGui.QWidget):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = MyMplCanvas()
        #self.toolbar = MyNavigationToolbar(self.canvas, self.canvas, direction = 'v')
        self.toolbar = NavigationToolbar(self.canvas, self.canvas)
        #self.toolbar.hide()
        self.hbox = QtGui.QHBoxLayout()
        #self.hbox.addWidget(self.toolbar)
        self.hbox.addWidget(self.canvas)
        self.setLayout(self.hbox)
        ##########################
        self.hZoom = QtGui.QAction("Zoom",  self)
        self.hZoom.setShortcut("Ctrl+Z")
        self.addAction(self.hZoom)
        QtCore.QObject.connect(self.hZoom,QtCore.SIGNAL("triggered()"), self.ZoomToggle)

        self.actionAutoScale = QtGui.QAction("AutoScale",  self)#self.MainWindow)
        self.actionAutoScale.setShortcut("Ctrl+A")
        self.addAction(self.actionAutoScale)
        QtCore.QObject.connect(self.actionAutoScale,QtCore.SIGNAL("triggered()"), self.autoscale_plot)

    def ZoomToggle(self):
        self.toolbar.zoom()

    def autoscale_plot(self):
        self.toolbar.home()
开发者ID:pombredanne,项目名称:toolz-1,代码行数:29,代码来源:mpl3D_custom_widget.py

示例2: MPL_Widget

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import zoom [as 别名]
class MPL_Widget(QtGui.QWidget):
    def __init__(self, parent = None):
        QtGui.QWidget.__init__(self, parent)
        self.canvas = MyMplCanvas()
        #self.toolbar = MyNavigationToolbar(self.canvas, self.canvas, direction = 'v')
        self.toolbar = NavigationToolbar(self.canvas, self.canvas)
        self.toolbar.hide()
        self.hbox = QtGui.QHBoxLayout()
        #self.hbox.addWidget(self.toolbar)
        self.hbox.addWidget(self.canvas)
        self.setLayout(self.hbox)
        ##########################
        self.hZoom = QtGui.QAction("Zoom",  self)
        self.hZoom.setShortcut("Ctrl+Z")
        self.addAction(self.hZoom)
        QtCore.QObject.connect(self.hZoom,QtCore.SIGNAL("triggered()"), self.ZoomToggle)

        self.actionAutoScale = QtGui.QAction("AutoScale",  self)#self.MainWindow)
        self.actionAutoScale.setShortcut("Ctrl+A")
        self.addAction(self.actionAutoScale)
        QtCore.QObject.connect(self.actionAutoScale,QtCore.SIGNAL("triggered()"), self.autoscale_plot)


        self.installEventFilter(EventFilter(self))

        ###########SAVING FIGURE TO CLIPBOARD##########
        self.cb = None #will be used for the clipboard
        self.tempPath = getHomeDir()
        self.tempPath = os.path.join(self.tempPath,'tempMPL.png')

    def ZoomToggle(self):
        self.toolbar.zoom()

    def autoscale_plot(self):
        self.toolbar.home()

    def mpl2Clip(self):
        try:
            self.canvas.fig.savefig(self.tempPath)
            tempImg = QtGui.QImage(self.tempPath)
            self.cb = QtGui.QApplication.clipboard()
            self.cb.setImage(tempImg)
        except:
            print 'Error copying figure to clipboard'
            errorMsg = "Sorry: %s\n\n:%s\n"%(sys.exc_type, sys.exc_value)
            print errorMsg

    def focusEvent(self, event):
#        self.enableAutoScale()
#        self.enableZoom()
        self.enableClip()
#        self.enableCSV()
        #print "Focus In %s"%self.canvas.plotTitle

    def lossFocusEvent(self, event):
#        self.disableAutoScale()
#        self.disableZoom()
        self.disableClip()
#        self.disableCSV()
        #print "Focus Out %s"%self.canvas.plotTitle

    def enableClip(self):
        self.mpl2ClipAction = QtGui.QAction("Save to Clipboard",  self)
        self.mpl2ClipAction.setShortcut("Ctrl+C")
        self.addAction(self.mpl2ClipAction)
        QtCore.QObject.connect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)

    def disableClip(self):
        QtCore.QObject.disconnect(self.mpl2ClipAction,QtCore.SIGNAL("triggered()"), self.mpl2Clip)
        self.removeAction(self.mpl2ClipAction)
开发者ID:pombredanne,项目名称:toolz-1,代码行数:72,代码来源:mplElemIso.py

示例3: zoom

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import zoom [as 别名]
 def zoom(self, *args):
   NavigationToolbar2QT.zoom(self, *args)
   self.activate_widget('zoom', not self.isZoomActivated)
开发者ID:JeanBilheux,项目名称:RefRed,代码行数:5,代码来源:mplwidgetxlog.py

示例4: Rt60Widget

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import zoom [as 别名]

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

      def on_motion(self, event):
           'on motion we will draw the line '
           if self.press is None: return
           x0, y0 = self.press
           x = x0, event.xdata
           y = y0, event.ydata 
           # the line that users get to draw
           #self.line, = self.canvas.ax.plot([0], [0])
           #self.line.set_color("red")
           #self.line.set_linewidth(1.5)
           #self.line.set_linestyle('-')

           self.line.set_data(x, y)   # this sets up the line to be drawn
           self.linex = x
           self.liney = y

           if (y[1] != y[0]):
               rt60 = -60.0*(x[1]-x[0])/(1.0*y[1]-y[0])
   #           print 'RT60(s)= ',rt60
               status_template = 'RT60 = %.2f s'
               self.status_text.set_text(status_template%(rt60))
               #octave_template = '%s Octave'
               #octave_text = str(self.parent.parent.canvas.mplcomboBox.currentText()) 
               #self.octave_text.set_text(octave_template%(octave_text))
               self.line.figure.canvas.draw()   # update the canvas

      def on_release(self, event):
           'on release we reset the press data'
           self.press = None
           mode = self.canvas.ax.get_navigate_mode() 
           # undo any zoom effects
           if ('ZOOM' == mode):
              self.navi_toolbar.zoom()
           return

      def disconnect(self):
           'disconnect all the stored connection ids'
           self.line.figure.canvas.mpl_disconnect(self.cidpress)
           self.line.figure.canvas.mpl_disconnect(self.cidrelease)
           self.line.figure.canvas.mpl_disconnect(self.cidmotion)



      def update_graph(self,amp,t,filenameA,ampB,tB, filenameB):
        print "in rt60's update_graph:  filenameA = %s" % filenameA
        """Updates the graph with new data/annotations"""
        #fig = pl.figure()
        #ax = fig.add_subplot(111)

        epsilon = 1.0e-8     # added to avoid log(0) errors

        # Compute the quantity to be plotted
        power = (amp + epsilon) **2
        maxval = 1.0*np.max(power)
        power = power / maxval
        dB = 10*np.ma.log10(np.abs(power))   # "ma"=masked array, throws out -Inf values


        # Downsample for plotting purposes.  (otherwise the plotting takes forever)
        nsamples = len(dB)
        if (nsamples > 100000):
           plotsamples = 2048
        elif (nsamples > 50000):
           plotsamples = 2048
        else:
开发者ID:drscotthawley,项目名称:SHAART,代码行数:70,代码来源:rt60widget.py

示例5: MPL_Widget

# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import zoom [as 别名]

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

    def enableCSV(self):
        self.saveCSVAction = QtGui.QAction("Save to CSV",  self)
        self.saveCSVAction.setShortcut("Ctrl+Alt+S")
        self.addAction(self.saveCSVAction)
        QtCore.QObject.connect(self.saveCSVAction,QtCore.SIGNAL("triggered()"), self.save2CSV)

    def disableCSV(self):
        QtCore.QObject.disconnect(self.saveCSVAction,QtCore.SIGNAL("triggered()"), self.save2CSV)
        self.removeAction(self.saveCSVAction)

    def setLineDict(self):
        self.lineDict = {}
        lineList = self.canvas.ax.get_lines()
        if lineList > 0:
            for line in lineList:
                self.lineDict[line.get_label()]=line

    def editPlotProperties(self):
        print "Edit Enabled"
        self.setLineDict()
#        if len(self.lineDict) > 0:
        curAx = self.canvas.ax
        if POD(self.lineDict, curAx = curAx, parent = self).exec_():
            if self.addLegend:
                curAx.legend(borderaxespad = 0.03, axespad=0.25)
            self.canvas.format_labels()
            self.canvas.draw()
        else:
            print "Cancel"


    def ZoomToggle(self):
        self.toolbar.zoom() #this implements the classic zoom
#        if self.hZoom:
#            self.hZoom = False
#            self.span.visible = False
#        else:
#            self.hZoom = True
#            self.span.visible = True

    def autoscale_plot(self):
        self.toolbar.home() #implements the classic return to home
#        self.canvas.ax.autoscale_view(tight = False, scalex=True, scaley=True)
#        self.canvas.draw()
#        self.emit(QtCore.SIGNAL("autoScaleAxis(bool)"),True)

#    def onclick(self, event):
#        #sets up the maximum Y level to be displayed after the zoom.
#        #if not set then it maxes to the largest point in the data
#        #not necessarily the local max
#        if event.ydata != None:
#            self.localYMax = int(event.ydata)
#
#    def onselect(self, xmin, xmax):
#        #print xmin,  xmax
#        if self.hZoom:
#            self.canvas.ax.set_ylim(ymax = self.localYMax)
#            self.canvas.ax.set_xlim(xmin, xmax)
#            self.canvas.draw()


    def save2CSV(self):
        path = self.SFDialog()
        if path != None:
            try:
开发者ID:pombredanne,项目名称:toolz-1,代码行数:70,代码来源:mpl_custom_widget.py


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