• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python backend_wx.FigureCanvasWx类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中matplotlib.backends.backend_wx.FigureCanvasWx的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasWx类的具体用法?Python FigureCanvasWx怎么用?Python FigureCanvasWx使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: PlotFigure

class PlotFigure(wxFrame):

    def __init__(self):
        wxFrame.__init__(self, None, -1, "Test embedded wxFigure")

        self.fig = Figure((5,4), 75)
        self.canvas = FigureCanvasWx(self, -1, self.fig)
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        tw, th = self.toolbar.GetSizeTuple()
        fw, fh = self.canvas.GetSizeTuple()
        self.toolbar.SetSize(wxSize(fw, th))

        # Create a figure manager to manage things
        self.figmgr = FigureManager(self.canvas, 1, self)
        # Now put all into a sizer
        sizer = wxBoxSizer(wxVERTICAL)
        # This way of adding to sizer allows resizing
        sizer.Add(self.canvas, 1, wxLEFT|wxTOP|wxGROW)
        # Best to allow the toolbar to resize!
        sizer.Add(self.toolbar, 0, wxGROW)
        self.SetSizer(sizer)
        self.Fit()
        EVT_TIMER(self, TIMER_ID, self.onTimer)
        
    def init_plot_data(self):
        a = self.figmgr.add_subplot(111)
        self.ind = numpy.arange(60)
        tmp = []
        for i in range(60):
            tmp.append(numpy.sin((self.ind+i)*numpy.pi/15))
        self.X = numpy.array(tmp)
        self.lines = a.plot(self.X[:,0],'o')
        self.count = 0

    def GetToolBar(self):
        # You will need to override GetToolBar if you are using an 
        # unmanaged toolbar in your frame
        return self.toolbar
		
    def onTimer(self, evt):
        self.count += 1
        if self.count >= 60: self.count = 0
        self.lines[0].set_data(self.ind, self.X[:,self.count])
        self.canvas.draw()
        self.canvas.gui_repaint()
开发者ID:,项目名称:,代码行数:49,代码来源:


示例2: __init__

    def __init__(self):
        wxFrame.__init__(self, None, -1, "Test embedded wxFigure")

        self.fig = Figure((5,4), 75)
        self.canvas = FigureCanvasWx(self, -1, self.fig)
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()

        # On Windows, default frame size behaviour is incorrect
        # you don't need this under Linux
        tw, th = self.toolbar.GetSizeTuple()
        fw, fh = self.canvas.GetSizeTuple()
        self.toolbar.SetSize(wxSize(fw, th))

        # Create a figure manager to manage things
        self.figmgr = FigureManager(self.canvas, 1, self)
        # Now put all into a sizer
        sizer = wxBoxSizer(wxVERTICAL)
        # This way of adding to sizer allows resizing
        sizer.Add(self.canvas, 1, wxLEFT|wxTOP|wxGROW)
        # Best to allow the toolbar to resize!
        sizer.Add(self.toolbar, 0, wxGROW)
        self.SetSizer(sizer)
        self.Fit()
        EVT_TIMER(self, TIMER_ID, self.onTimer)
开发者ID:,项目名称:,代码行数:25,代码来源:


示例3: draw_all

 def draw_all(self, drawDC=None):
     ''' 
     draw everything from scratch 
     mostly debugging purpose
     '''
     print('draw_all')
     self.figure.figobj.reset_axesbmp_update()
     Canvas.draw(self)
开发者ID:piScope,项目名称:piScope,代码行数:8,代码来源:backend_wx_mod.py


示例4: CanvasFrame

class CanvasFrame(Frame):

    def __init__(self):
        Frame.__init__(self, None, -1,
                         'CanvasFrame', size=(550, 350))

        self.SetBackgroundColour(NamedColor("WHITE"))

        self.figure = Figure(figsize=(5, 4), dpi=100)
        self.axes = self.figure.add_subplot(111)
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * t)

        self.axes.plot(t, s)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = BoxSizer(VERTICAL)
        self.sizer.Add(self.canvas, 1, TOP | LEFT | EXPAND)
        # Capture the paint message
        EVT_PAINT(self, self.OnPaint)

        self.toolbar = MyNavigationToolbar(self.canvas, True)
        self.toolbar.Realize()
        if Platform == '__WXMAC__':
            # Mac platform (OSX 10.3, MacPython) does not seem to cope with
            # having a toolbar in a sizer. This work-around gets the buttons
            # back, but at the expense of having the toolbar at the top
            self.SetToolBar(self.toolbar)
        else:
            # On Windows platform, default window size is incorrect, so set
            # toolbar width to figure width.
            tw, th = self.toolbar.GetSizeTuple()
            fw, fh = self.canvas.GetSizeTuple()
            # By adding toolbar in sizer, we are able to put it at the bottom
            # of the frame - so appearance is closer to GTK version.
            # As noted above, doesn't work for Mac.
            self.toolbar.SetSize(Size(fw, th))
            self.sizer.Add(self.toolbar, 0, LEFT | EXPAND)

        # update the axes menu on the toolbar
        self.toolbar.update()
        self.SetSizer(self.sizer)
        self.Fit()


    def OnPaint(self, event):
        self.canvas.draw()
        event.Skip()
开发者ID:michaelaye,项目名称:pymars,代码行数:49,代码来源:wxmpl_custom_toolbar.py


示例5: View

class View(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='QRS detect')
        self.SetBackgroundColour(wx.NamedColour("WHITE"))
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        #self.axes.plot(t, s)
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  

        
    def add_toolbar(self):
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        if wx.Platform == '__WXMAC__':
            self.SetToolBar(self.toolbar)
        else:
            # On Windows platform, default window size is incorrect, so set
            # toolbar width to figure width.
            tw, th = self.toolbar.GetSizeTuple()
            fw, fh = self.canvas.GetSizeTuple()
            # By adding toolbar in sizer, we are able to put it at the bottom
            # of the frame - so appearance is closer to GTK version.
            # As noted above, doesn't work for Mac.
            self.toolbar.SetSize(wx.Size(fw, th))
            self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()


    def plot(ecg1, ecg2, marks=None):
        """
        Plot will show two ECG leads, each with the marks, if available
        Last row will be rr intervals
        """
        if marks == None:
            self.axes.plot(ecg1)

        
    def OnPaint(self, event):
        self.canvas.draw()
开发者ID:jameslatham,项目名称:ecgtk,代码行数:48,代码来源:rdetect.py


示例6: __init__

   def __init__(self, title='', verb=1):
      wx.Frame.__init__(self, None, -1, title, size=(400,300))
      self.verb   = verb
      self.figure = Figure()
      self.canvas = FigureCanvas(self, -1, self.figure)
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
      self.SetSizer(self.sizer)
      self.Fit()

      # toolbar?
      # self.toolbar = NavigationToolbar2Wx(self.canvas)
      # self.toolbar.Realize()
      # self.sizer.Add(self.toolbar, 0, wx.BOTTOM | wx.EXPAND)
      # self.toolbar.update()

      # axis plotting info
      self.ax     = None
      self.xmin   = 1.0
      self.xmax   = 0.0
      self.ymin   = 1.0
      self.ymax   = 0.0
      self.xlabel = ''
      self.ylabel = ''
      self.style  = 'graph'

      self.images = []

      self.toolbar = NavigationToolbar2Wx(self.canvas)
      self.toolbar.Realize()
      self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
      self.toolbar.update()
开发者ID:neurodebian,项目名称:afni,代码行数:32,代码来源:lib_RR_plot.py


示例7: Plotter

class Plotter(wx.Panel):
    " Simple plotter class"
    def __init__(self,parent):
        self.parent = parent
        wx.Panel.__init__(self,parent,-1,size=(50,50))
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.figure = matplotlib.figure.Figure()
        self.axPhase = self.figure.add_subplot(211)
        self.axPhase.hold(False)
        self.axU = self.figure.add_subplot(212)
        self.axU.hold(False)
        self.figure.subplots_adjust(hspace=0.5)
        self.canvas = FigureCanvas(self,-1,self.figure)
        self.sizer.Add(self.canvas)
        self.navtoolbar = NavigationToolbar2Wx(self.canvas)
        self.sizer.Add(self.navtoolbar)
        self.SetSizer(self.sizer)
        self.Fit()

    def plotPhaseFunction(self,phasefunction):
        " Plot the phase function, requires a pure function "
        # create x-axis
        wavelength = np.linspace(600,900,1000)
        #phasefunction is dependent on frequency, not wavelength, so convert
        vFun = np.vectorize(phasefunction)
        phases = vFun(w2f(wavelength))
        #print np.array([wavelength,phases]).transpose()
        self.axPhase.plot(wavelength,phases)
        self.axPhase.set_xlabel("Wavelength [nm]")
        self.axPhase.set_ylabel("Phase [rad]")
        self.canvas.draw()

    def plotVoltages(self,phasefunction):
        " Plot the voltages as a function of pixel index "
        # create x-axis
        x = np.arange(640)
        # get the data: do apply_phase with simulateOnly=True
        print "     PATTERN"
        pattern = self.parent.slmCal.apply_phase_on_freq(phasefunction,simulateOnly=True)
        self.axU.plot(x,pattern,'-x')
        self.axU.set_xlabel("Pixel index #")
        self.axU.set_ylabel("Voltage")
        self.canvas.draw()
开发者ID:dboonz,项目名称:slmGui,代码行数:43,代码来源:slmGui.py


示例8: __init__

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='QRS detect')
        self.SetBackgroundColour(wx.NamedColour("WHITE"))
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        #self.axes.plot(t, s)
        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_toolbar()  
开发者ID:jameslatham,项目名称:ecgtk,代码行数:15,代码来源:rdetect.py


示例9: __init__

 def __init__(self,parent):
     self.parent = parent
     wx.Panel.__init__(self,parent,-1,size=(50,50))
     self.sizer = wx.BoxSizer(wx.VERTICAL)
     self.figure = matplotlib.figure.Figure()
     self.axPhase = self.figure.add_subplot(211)
     self.axPhase.hold(False)
     self.axU = self.figure.add_subplot(212)
     self.axU.hold(False)
     self.figure.subplots_adjust(hspace=0.5)
     self.canvas = FigureCanvas(self,-1,self.figure)
     self.sizer.Add(self.canvas)
     self.navtoolbar = NavigationToolbar2Wx(self.canvas)
     self.sizer.Add(self.navtoolbar)
     self.SetSizer(self.sizer)
     self.Fit()
开发者ID:dboonz,项目名称:slmGui,代码行数:16,代码来源:slmGui.py


示例10: __init__

   def __init__(self, title='', as_one=0, verb=1):
      wx.Frame.__init__(self, None, -1, title, size=(400,300))
      self.verb   = verb
      self.figure = Figure()
      self.canvas = FigureCanvas(self, -1, self.figure)
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
      self.SetSizer(self.sizer)
      self.Fit()

      self.canvas.mpl_connect('key_press_event', self.cb_keypress)
      self.as_one  = as_one

      self.toolbar = NavigationToolbar2Wx(self.canvas)
      self.toolbar.Realize()
      self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
      self.toolbar.update()
开发者ID:neurodebian,项目名称:afni,代码行数:17,代码来源:gui_xmat.py


示例11: __init__

    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='QRS detect')
        self.SetBackgroundColour(wx.NamedColour("WHITE"))
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()
        
        self.add_toolbar()  
        # http://stackoverflow.com/questions/4740988/add-new-navigate-modes-in-matplotlib
        self.pan_tool  = self.toolbar.FindById(
                         self.toolbar._NTB2_PAN)
        self.zoom_tool = self.toolbar.FindById(
                         self.toolbar._NTB2_ZOOM)
开发者ID:Basildcruz,项目名称:ecgtk,代码行数:19,代码来源:rdetect.py


示例12: CanvasFrame

class CanvasFrame(wx.Frame):
   """create a main plotting canvas
        title   : optional window title
        verb    : verbose level (default 1)
   """

   counter = 0
   def __init__(self, title='', verb=1):
      wx.Frame.__init__(self, None, -1, title, size=(400,300))
      self.verb   = verb
      self.figure = Figure()
      self.canvas = FigureCanvas(self, -1, self.figure)
      self.sizer = wx.BoxSizer(wx.VERTICAL)
      self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
      self.SetSizer(self.sizer)
      self.Fit()

      # toolbar?
      # self.toolbar = NavigationToolbar2Wx(self.canvas)
      # self.toolbar.Realize()
      # self.sizer.Add(self.toolbar, 0, wx.BOTTOM | wx.EXPAND)
      # self.toolbar.update()

      # axis plotting info
      self.ax     = None
      self.xmin   = 1.0
      self.xmax   = 0.0
      self.ymin   = 1.0
      self.ymax   = 0.0
      self.xlabel = ''
      self.ylabel = ''
      self.style  = 'graph'

      self.images = []

      self.toolbar = NavigationToolbar2Wx(self.canvas)
      self.toolbar.Realize()
      self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
      self.toolbar.update()

   def cb_keypress(self, event):
      if event.key == 'q':
         self.Close()

   def set_limits(self, xmin=1.0, xmax=0.0, ymin=1.0, ymax=0.0):
      """if xmin < xmax: apply, and similarly for y"""
      if xmin < xmax:
         self.xmin = xmin
         self.xmax = xmax
         if self.verb > 2: print '-- resetting xlimits to:', xmin, xmax
      if ymin < ymax:
         self.ymin = ymin
         self.ymax = ymax
         if self.verb > 2: print '-- resetting ylimits to:', ymin, ymax

   def plot_data(self, data, title=''):
      """plot data
         style can be 'graph' or 'bar'"""

      if self.ax == None:
         self.ax = self.figure.add_subplot(1,1,1,title=title)

      self.ax.clear()

      if self.style == 'graph':
         self.ax.plot(data)
         self.ax.grid(True)
      else:     # bars of width 1
         offsets = N.arange(len(data))
         bars = self.ax.bar(offsets, data, 1)

      self.ax.set_xlabel(self.xlabel)
      self.ax.set_ylabel(self.ylabel)

      # after data is plotted, set limits
      if self.xmin < self.xmax: self.ax.set_xlim((self.xmin, self.xmax))
      if self.ymin < self.ymax: self.ax.set_ylim((self.ymin, self.ymax))

      self.Fit()        # maybe not applied without a running app loop
      self.canvas.draw()

   def exit(self):
      self.Destroy()
开发者ID:neurodebian,项目名称:afni,代码行数:83,代码来源:lib_RR_plot.py


示例13: __init__

 def __init__(self, *args, **kargs):
     Canvas.__init__(self, *args, **kargs)
     CanvasMod.__init__(self, *args, **kargs)
开发者ID:piScope,项目名称:piScope,代码行数:3,代码来源:backend_wx_mod.py


示例14: CanvasFrame

class CanvasFrame(wx.Frame):
    """create a main plotting canvas
        title   : optional window title
        as_one  : plot as one overlapping graph
                  (else a list of scaled graphs)
        verb    : verbose level (default 1)
   """

    counter = 0

    def __init__(self, title="", as_one=0, verb=1):
        wx.Frame.__init__(self, None, -1, title, size=(400, 300))
        self.counter += 1
        self.verb = verb
        self.figure = Figure()
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.canvas.mpl_connect("key_press_event", self.cb_keypress)
        self.as_one = as_one

        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        self.toolbar.update()

    def cb_keypress(self, event):
        if event.key == "q":
            self.Close()

    def plot_scaled_mat(self, amat, verb=1):
        """plot data scaled and shifted to fit on one graph

              data      - AfniMatrix, list of float lists, or 1D file
              title     - optional window title
              verb      - optional verbose level
      """

        # allow matlist, list of float lists,
        # if type(matlist) == type([]):
        #     e0 = matlist[0]
        #     if type

        if not matlist:
            return
        nmats = len(matlist)
        if nmats < 1:
            return

        yformat = FormatStrFormatter("%5.1f")

    def plot_matlist(self, matlist, title="", ylabels=[], ftcolors=0, verb=1):
        """plot AfniMatrix list, one graph per AfniMatrix
              matlist   - list of AfniMatrix elements
              title     - optional window title
              ylabels   - optional list of ylabel per mat
              ftcolors  - flag: use fit/timeseries colors (black blue)
              verb      - optional verbose level
      """

        if not matlist:
            return
        nmats = len(matlist)
        if nmats < 1:
            return

        yformat = FormatStrFormatter("%5.1f")
        matplotlib.rcParams["lines.linewidth"] = 2

        # make a label list, and get max length (among any label[0])
        if ylabels:
            labels = ylabels
        else:
            labels = []
        rlen = 0
        nruns = 0
        maxlen = 0
        for ind in range(nmats):
            if ylabels:
                lab = ylabels[ind]
            else:
                if matlist[ind].labels:
                    lab = matlist[ind].labels[0]
                else:
                    lab = ""
                labels.append(lab)
            if len(lab) > maxlen:
                maxlen = len(lab)

            # note run info
            if nruns == 0 and matlist[ind].nruns > 1:
                nruns = matlist[ind].nruns
                rlen = matlist[ind].run_len

        for ind in range(nmats):
            amat = matlist[ind]

#.........这里部分代码省略.........
开发者ID:neurodebian,项目名称:afni_removeme_eventually,代码行数:101,代码来源:lib_matplot.py


示例15: View

class View(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='QRS detect')
        self.SetBackgroundColour(wx.NamedColour("WHITE"))
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()
        
        self.add_toolbar()  
        # http://stackoverflow.com/questions/4740988/add-new-navigate-modes-in-matplotlib
        self.pan_tool  = self.toolbar.FindById(
                         self.toolbar._NTB2_PAN)
        self.zoom_tool = self.toolbar.FindById(
                         self.toolbar._NTB2_ZOOM)
        

        
    def add_toolbar(self):
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        if wx.Platform == '__WXMAC__':
            self.SetToolBar(self.toolbar)
        else:
            # On Windows platform, default window size is incorrect, so set
            # toolbar width to figure width.
            tw, th = self.toolbar.GetSizeTuple()
            fw, fh = self.canvas.GetSizeTuple()
            # By adding toolbar in sizer, we are able to put it at the bottom
            # of the frame - so appearance is closer to GTK version.
            # As noted above, doesn't work for Mac.
            self.toolbar.SetSize(wx.Size(fw, th))
            self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()


    def init_plot(self, ecg1, ecg2, marks):
        """
        Plot will show two ECG leads, each with the marks, if available
        Last row will be rr intervals
        """
        ecg1 += (ecg2.max() -  ecg2.min())

        self.axes.plot(ecg1, 'b')
        self.axes.plot(ecg2, 'b')
        if marks != None:
            for samp, label in marks:
                self.axes.plot(samp, ecg1[samp], 'ok')
                self.axes.plot(samp, ecg2[samp], 'ok')

    def add_mark(self, x, y1, y2):
        """
        New mark to be plotted.
        y1 and y2 are heights for lead1 and lead2
        """
        self.axes.plot(x, y1, 'ok')
        self.axes.plot(x, y2, 'ok')
        self.canvas.draw()
        
    def remove_mark(self, x, y1, y2):
        """
        Remove existing marks from leads 1 and 2
        Draw red cross over to denote remove
        """
        print 'plotting at', x, y1
        self.axes.plot(x, y1, 'xr')
        self.axes.plot(x, y2, 'xr')
        self.canvas.draw()
        

    def _get_xrange(self):
        xmin, xmax = self.axes.get_xbound()
        return xmax - xmin
        
                
    def OnPaint(self, event):
        self.canvas.draw()
开发者ID:Basildcruz,项目名称:ecgtk,代码行数:83,代码来源:rdetect.py


示例16: View

class View(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, title='QRS detect')
        self.SetBackgroundColour(wx.NamedColour("WHITE"))
        self.figure = Figure()
        self.axes = self.figure.add_subplot(111)

        self.canvas = FigureCanvas(self, -1, self.figure)

        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

        self.add_menubar()
        
        self.add_toolbar()  
        # http://stackoverflow.com/questions/4740988/add-new-navigate-modes-in-matplotlib
        self.pan_tool  = self.toolbar.FindById(
                         self.toolbar._NTB2_PAN)
        self.zoom_tool = self.toolbar.FindById(
                         self.toolbar._NTB2_ZOOM)

        self.Bind(wx.EVT_CLOSE, self.on_close)


    def on_close(self, event):
        pub.sendMessage("VIEW CLOSED")
        
        
    def add_toolbar(self):
        self.toolbar = NavigationToolbar2Wx(self.canvas)
        self.toolbar.Realize()
        if wx.Platform == '__WXMAC__':
            self.SetToolBar(self.toolbar)
        else:
            # On Windows platform, default window size is incorrect, so set
            # toolbar width to figure width.
            tw, th = self.toolbar.GetSizeTuple()
            fw, fh = self.canvas.GetSizeTuple()
            # By adding toolbar in sizer, we are able to put it at the bottom
            # of the frame - so appearance is closer to GTK version.
            # As noted above, doesn't work for Mac.
            self.toolbar.SetSize(wx.Size(fw, th))
            self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND)
        # update the axes menu on the toolbar
        self.toolbar.update()


    def add_menubar(self):
        """
        Loading and saving will be available in the menu
        """
        menubar = wx.MenuBar()

        file_menu = wx.Menu()
        file_menu.Append(ID_LOAD, "&Load", "Load ECG and/or annotation")
        file_menu.Append(ID_MARK, "&Annotate", "Generate new annotation")
        file_menu.Append(ID_SAVE, "&Save", "Save annotations")

        channel_menu = wx.Menu()
        channel_menu.Append(ID_CHANGE_CHANNEL, "&Change Chan 1",
                            "Change channel 1")
        
        menubar.Append(file_menu, "&File")
        menubar.Append(channel_menu, "&Channel")
        
        self.SetMenuBar(menubar)
        

    def init_plot(self, ecg1, ecg2, marks):
        """
        Plot will show two ECG leads, each with the marks, if available
        Last row will be rr intervals
        """
        print 'Plotting'
        ecg1, ecg2 = self.remove_overlap(ecg1, ecg2)

        # if zoomed in, maintain x axis zoom
        minx, maxx =  self.axes.get_xlim()

        self.axes.clear()
        self.axes.plot(ecg1, 'b')
        self.axes.plot(ecg2, 'b')
        if marks != None:
            for samp, label in marks:
                self.axes.plot(samp, ecg1[samp], 'ok')
                self.axes.plot(samp, ecg2[samp], 'ok')

        if maxx != 1.0: # which is the default without a plot
            self.axes.set_xlim(minx, maxx)
                
        self.canvas.draw()


    def remove_overlap(self, ecg1, ecg2):
        """
        Adjust baseline of ecg1 so that it doesnt overlap
        with ecg2
        """
#.........这里部分代码省略.........
开发者ID:Basildcruz,项目名称:ecgtk,代码行数:101,代码来源:markedit.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python backend_wxagg.FigureCanvasWxAgg类代码示例发布时间:2022-05-27
下一篇:
Python backend_wx._load_bitmap函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap