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


Python FigureCanvasWx.draw方法代码示例

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


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

示例1: draw_all

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
 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,代码行数:10,代码来源:backend_wx_mod.py

示例2: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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:,项目名称:,代码行数:51,代码来源:

示例3: CanvasFrame

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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,代码行数:51,代码来源:wxmpl_custom_toolbar.py

示例4: View

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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,代码行数:50,代码来源:rdetect.py

示例5: Plotter

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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,代码行数:45,代码来源:slmGui.py

示例6: CanvasFrame

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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,代码行数:85,代码来源:lib_RR_plot.py

示例7: CanvasFrame

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]

#.........这里部分代码省略.........
            width = ymax - ymin
            if ymin * ymax < 0.0:
                ymean = 0.0
            else:
                ymean = round((ymin + ymax) / 2.0, 2)

            ax.grid(True)

            ax.yaxis.set_major_formatter(yformat)

            # if there are many graphs, reduce the number of yticks
            if nmats > 10:
                ax.set_yticks(N.array([ymin, ymax]))
            elif nmats > 2:
                ax.set_yticks(N.array([ymin, ymean, ymax]))

            if rlen > 0:
                ax.set_xticks(N.array([r * rlen for r in range(nruns + 1)]))
            if ind < nmats - 1:
                ax.set_xticklabels([])
            else:
                ax.set_xlabel("TRs")

            if labels:
                if nmats > 1:
                    ax.set_ylabel("%-*s " % (maxlen, labels[ind]), rotation="horizontal")
                    rv, plist = self.axis_posn(ax)
                    if rv == 0:
                        ax.set_position((0.15, plist[1], 0.7, 0.7 / nmats))
                else:
                    ax.set_ylabel("%s" % labels[ind])
                    ax.set_position((0.15, 0.2, 0.7, 0.7))

        self.canvas.draw()

        matplotlib.rcParams["lines.linewidth"] = 1  # reset

    def axis_posn(self, ax):
        """return error code, posn array"""

        # first attempt is to look for simple array return
        try:
            posn = ax.get_position()
        except:
            if self.verb > 1:
                print "** failed ax.get_position()"
            return 1, None

        # have list, ready for some return
        if type(posn) == type([]):
            if len(posn) < 4:
                if self.verb > 1:
                    print "** get_position returns len %d list" % len(posn)
                return 1, None
            if self.verb > 2:
                print "-- get_position returns list %s" % UTIL.float_list_string(posn)
            return 0, posn

        # no list, assume Bbox and expect get_points() to return 2x2 numpy array
        try:
            plist = posn.get_points()
        except:
            if self.verb > 1:
                print "** failed posn.get_points()"
            return 1, None
开发者ID:neurodebian,项目名称:afni_removeme_eventually,代码行数:69,代码来源:lib_matplot.py

示例8: View

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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,代码行数:85,代码来源:rdetect.py

示例9: View

# 需要导入模块: from matplotlib.backends.backend_wx import FigureCanvasWx [as 别名]
# 或者: from matplotlib.backends.backend_wx.FigureCanvasWx import draw [as 别名]
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,代码行数:103,代码来源:markedit.py


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