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


Python backend_wxagg.FigureCanvasWxAgg类代码示例

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


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

示例1: panAll

    def panAll(self, x, y, axesList):
        """
        Pans across multiple subplots simultaneously.  Use this
        function rather than pan to avoid lag on the x-axis.
        """
        if not self.enabled:    return

        i=0
        movex, movey = 0, 0
        xmin, xmax = 0, 0
        for axes in axesList:
            if not is_log_x(axes):
                xtick = axes.get_xaxis()._get_tick(major=False)._size
                movex = (self.getX() - x) / xtick / 10
                # TBF: matplotlib's Axes' panx method is broken, so we do it here
                axes.xaxis.pan(movex)
                if i==0:    # we want to keep all plots on a common x-axis
                    xmin, xmax = axes.viewLim.intervalx().get_bounds()
                axes.set_xlim(xmin, xmax)
                axes._send_xlim_event()
            if not is_log_y(axes):
                ytick = axes.get_yaxis()._get_tick(major=False)._size
                movey = (self.getY() - y) / ytick / 10
                axes.pany(movey)
            i += 1

        self.panx += movex
        self.pany += movey
        self.setX(x)
        self.setY(y)

        FigureCanvasWxAgg.draw(self.getView())
开发者ID:nrao,项目名称:deap,代码行数:32,代码来源:PlotView.py

示例2: rightButtonUp

    def rightButtonUp(self, evt, x, y):
        """
        Completely overrides base class functionality.
        """
        view = self.getView()

        if self.selectedAxes is None:
            axes, xdata, ydata = self.find_axes(view, x, y)
        else:
            axes = self.selectedAxes
            xdata, ydata = get_data(axes, x, y)

        self.setActiveSubplot(axes)

        if self.zoomEnabled and self.rightClickUnzoom:
            xmin = xmax = None
            for axes in self.find_all_axes(view, x, y): # unzoom all axes
                self.limits.restore(axes)
                if not self.limits.can_unzoom(axes):
                    # rescale manually - wxmpl will try to autoscale
                    if xmin is None or xmax is None: # make sure x-axis matches
                        xmin, xmax = axes.viewLim.intervalx().get_bounds()
                    axes.set_xlim(xmin, xmax)
                    axes._send_xlim_event()
            view.crosshairs.clear()
            view.draw()
            view.crosshairs.set(x, y)

        if self.IsInfoMode() and axes is not None:
            self.DisplayAllSubplots()
            FigureCanvasWxAgg.draw(view)

        if self.IsPanMode() and axes is not None:
            self.panTool.end_pan_all(x, y, self.find_all_axes(view, x, y))
开发者ID:nrao,项目名称:deap,代码行数:34,代码来源:PlotView.py

示例3: __init__

    def __init__(self, parent, *args, **kwargs):
        """wx.Panel with a matplotlib figure

        Parameters
        ----------
        figsize : tuple
            Figure dimensions (width, height) in inches
        dpi : int
            Dots per inch.
        facecolor : mpl color
            The figure patch facecolor; defaults to rc ``figure.facecolor``
        edgecolor : mpl color
            The figure patch edge color; defaults to rc ``figure.edgecolor``
        linewidth : scalar
            The figure patch edge linewidth; the default linewidth of the frame
        frameon : bool
            If ``False``, suppress drawing the figure frame
        subplotpars :
            A :class:`SubplotParams` instance, defaults to rc
        tight_layout : bool | dict
            If ``False`` use ``subplotpars``; if ``True`` adjust subplot
            parameters using :meth:`tight_layout` with default padding.
            When providing a dict containing the keys `pad`, `w_pad`, `h_pad`
            and `rect`, the default :meth:`tight_layout` paddings will be
            overridden. Defaults to rc ``figure.autolayout``.
        """
        self.figure = Figure(*args, **kwargs)
        FigureCanvasWxAgg.__init__(self, parent, wx.ID_ANY, self.figure)
        self.Bind(wx.EVT_ENTER_WINDOW, self.ChangeCursor)
开发者ID:awjamison,项目名称:Eelbrain,代码行数:29,代码来源:mpl_canvas.py

示例4: PageThree

class PageThree(wx.Panel):
	def __init__(self, parent):
		wx.Panel.__init__(self, parent)
	
		self.figure = Figure(dpi=50)
		
		self.canvas = FigureCanvasWxAgg(self, -1, self.figure)
		self.toolbar = NavigationToolbar2Wx(self.canvas)
		self.toolbar.Realize()
		
		self.plotLast = wx.Button(self,-1,label="Plot Last")
		self.Bind(wx.EVT_BUTTON, self.plotLastButtonClick, self.plotLast)

		topSizer = wx.BoxSizer(wx.HORIZONTAL)
		sizer = wx.BoxSizer(wx.VERTICAL)
		topSizer.Add(self.plotLast, 0, wxFIXED_MINSIZE)
		topSizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
		sizer.Add(topSizer,1,wx.GROW)
		sizer.Add(self.toolbar, 0, wx.GROW)
		self.SetSizer(sizer)
		self.Fit()
		
	def plotLastButtonClick(self, evt):
		gh.plotGraph(self.figure)
		self.canvas.draw()
开发者ID:michaelcoe,项目名称:robotGUI,代码行数:25,代码来源:RobotGUI.py

示例5: rightButtonUp

    def rightButtonUp(self, evt, x, y):
        """
        Completely overrides base class functionality.
        """
        view = self.getView()

        if self.selectedAxes is None:
            axes, xdata, ydata = wxmpl.find_axes(view, x, y)
        else:
            axes = self.selectedAxes
            xdata, ydata = get_data(axes, x, y)

        self.setActiveSubplot(axes)

        if (axes is not None and self.zoomEnabled and self.rightClickUnzoom
        and self.limits.restore(axes)):
            view.crosshairs.clear()
            view.draw()
            view.crosshairs.set(x, y)

        if self.IsInfoMode() and axes is not None:
            self.DisplayAllSubplots()
            FigureCanvasWxAgg.draw(view)

        if self.IsPanMode() and axes is not None:
            self.panTool.end_pan(x, y, axes)
开发者ID:emcnany,项目名称:deap,代码行数:26,代码来源:PlotView.py

示例6: pan

    def pan(self, x, y, axes):
        """
        Modifies the desired axes limits to make it appear to the user that the
        axes are panning as he/she moves the mouse.
        """
        if not self.enabled: return

        if not is_log_x(axes):
            xtick = axes.get_xaxis()._get_tick(major=False)._size
            movex = (self.getX() - x) / xtick / 10
            # TBF: matplotlib's Axes' panx method is broken, so we do it here
            #      in the next two lines for them.
            axes.xaxis.pan(movex)
            axes._send_xlim_event()
            self.panx += movex
        if not is_log_y(axes):
            ytick = axes.get_yaxis()._get_tick(major=False)._size
            movey = (self.getY() - y) / ytick / 10
            axes.pany(movey)
            self.pany += movey

        self.setX(x)
        self.setY(y)

        FigureCanvasWxAgg.draw(self.getView())
开发者ID:nrao,项目名称:deap,代码行数:25,代码来源:PlotView.py

示例7: end_pan_all

    def end_pan_all(self, x, y, axesList):
        """
        End panning for multiple subplots.  Use this function
        to correctly reset limits for all axes.
        """

        if not self.enabled: return
        i = 0
        xmin, xmax = 0, 0
        for axes in axesList:
            if not is_log_x(axes):
                # TBF: matplotlib's Axes' panx method is broken, so we do it
                #      here for them.
                axes.xaxis.pan(-self.panx)
                if i==0:    # we want to keep all plots on a common x-axis
                    xmin, xmax = axes.viewLim.intervalx().get_bounds()
                axes.set_xlim(xmin, xmax)
                axes._send_xlim_event()

            if not is_log_y(axes):
                axes.pany(-self.pany)
                axes._send_ylim_event()

            i += 1

        self.panx = 0
        self.pany = 0

        FigureCanvasWxAgg.draw(self.getView())
开发者ID:nrao,项目名称:deap,代码行数:29,代码来源:PlotView.py

示例8: ChartCanvas

class ChartCanvas():
    """
    Container for the matplotlib (or any other) chart object
    """
    def __init__(self, container, config):
        # Create the matplotlib figure and attach it to a canvas
        self.figure = Figure(
            (config.chart_width, config.chart_height),
            dpi=config.chart_dpi)
        self.canvas = FigureCanvasWxAgg(container, -1, self.figure)
        self.chart = self.figure.add_subplot(111)

    def layout(self):
        return self.canvas

    def draw(self, data, _):
        """
        Redraw figure
        """
        logging.debug('Redrawing time series')

        self.chart.clear()
        # self.axes.grid(self.cb_grid.IsChecked())

        self.chart.plot(data['dates'], data['values'])
        self.figure.autofmt_xdate()
        self.canvas.draw()
开发者ID:lhoghu,项目名称:python-tools,代码行数:27,代码来源:gui.py

示例9: Plot

class Plot(wx.Panel):
  def __init__(self, parent, dpi=None, **kwargs):
    wx.Panel.__init__(self, parent, **kwargs)
    self.figure = mpl.figure.Figure(dpi=dpi, figsize=(2, 2))
    self.canvas = Canvas(self, wx.ID_ANY, self.figure)

    self.check = wx.CheckBox(self, wx.ID_ANY, "Show contour")
    self.Bind(wx.EVT_CHECKBOX, self.OnChange, self.check)

    self.distMod = SinModulator(self, 'Amplitude modulator', cycles=(2,100), phase=(0, 999))
    self.Bind(EVT_UPDATE_EVENT, self.OnChange, self.distMod)

    sizerV = wx.BoxSizer(wx.VERTICAL)
    sizerV.Add(self.distMod)
    sizerV.Add(self.check, 0, wx.EXPAND)

    sizerH = wx.BoxSizer(wx.HORIZONTAL)
    sizerH.Add(self.canvas, 0, wx.SHAPED | wx.EXPAND)
    sizerH.Add(sizerV)

    self.SetSizer(sizerH)
    
    self.width, self.height = 256, 256

  def CalcPixel(self, i, j):
    x = 2.0 * i / self.width - 1.0
    y = 2.0 * j / self.height - 1.0
    dist = np.sqrt(x**2 + y**2) 
    angle = np.arctan2(y, x)

    data = self.distMod

    if data.active:
      phase = data.phase * 2.0 * np.pi 
      newAngle = angle * data.cycles + phase
      distDiff = np.cos(newAngle) * dist / data.cycles
    else:
      distDiff = 0.0

    return 1.0 - (dist + distDiff) 

  def Draw(self):
    self.figure.clear()
    subplot = self.figure.add_subplot(111)

    x = np.arange(0.0, self.width, 1.0)
    y = np.arange(0.0, self.height, 1.0)
    I, J = np.meshgrid(x, y)
    C = np.clip(self.CalcPixel(I, J), 0.0, 1.0)

    if self.check.IsChecked():
      self.CS = subplot.contour(I, J, C)
      subplot.clabel(self.CS, inline=0.1, fontsize=8)

    im = subplot.imshow(C, cmap=cm.gray)
    im.set_interpolation('bilinear')

  def OnChange(self, _):
    self.Draw()
    self.canvas.draw()
开发者ID:argasek,项目名称:morphine,代码行数:60,代码来源:genlight.py

示例10: CanvasPanel

class CanvasPanel(wx.Panel):
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        self.figure = Figure(facecolor="black")
        self.axes = self.figure.add_axes((0, 0, 1, 1))
        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.axes.set_axis_bgcolor('black')
        self.delta = 0
        
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * (t))
        self.datatoplot, = self.axes.plot(t, s, 'w', linewidth=3.0)
        self.axes.set_ylim((-10,10))
        self.axes.grid(True, color="w")
        
    def draw(self):
        self.delta = (self.delta + 0.05) % 1
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * (t-self.delta))
        self.datatoplot.set_ydata(s)
        
        wx.CallLater(10, self.draw)
        self.canvas.draw()
        self.canvas.Refresh()
开发者ID:Zhang--Ning,项目名称:staBP,代码行数:29,代码来源:plot.py

示例11: _create_canvas

    def _create_canvas(self, parent):
        
        panel = QtGui.QWidget()
        
        def mousemoved(event):           
            if event.xdata is not None:
                x, y = event.xdata, event.ydata
                name = "Axes"
            else:
                x, y = event.x, event.y
                name = "Figure"
                
            panel.info.setText("%s: %g, %g" % (name, x, y))
            
        panel.mousemoved = mousemoved
        vbox = QtGui.QVBoxLayout()
        panel.setLayout(vbox)
        
        mpl_control = FigureCanvas(self.value) #❷
        vbox.addWidget(mpl_control)
        if hasattr(self.value, "canvas_events"):
            for event_name, callback in self.value.canvas_events:
                mpl_control.mpl_connect(event_name, callback)

        mpl_control.mpl_connect("motion_notify_event", mousemoved)  

        if self.factory.toolbar: #❸
            toolbar = Toolbar(mpl_control, panel)
            vbox.addWidget(toolbar)       

        panel.info = QtGui.QLabel(panel)
        vbox.addWidget(panel.info)
        return panel    
开发者ID:Andor-Z,项目名称:scpy2,代码行数:33,代码来源:mpl_figure_editor.py

示例12: __init__

    def __init__(self,parent):
        self.data_t = [0]
        self.data_y = [0]
        self.data_y2 = [0]

        self.dpi = 100
        self.fig = Figure((3.0, 3.0), dpi=self.dpi)

        self.axes = self.fig.add_subplot(111)
        pylab.setp(self.axes.get_xticklabels(), fontsize=10)
        pylab.setp(self.axes.get_yticklabels(), fontsize=10)

        # plot the data as a line series, and save the reference 
        # to the plotted line series
        #
        self.plot_data = self.axes.plot(
            self.data_t,self.data_y,'y',
            self.data_t,self.data_y2,'c',
            )

        ymin = -30
        ymax = 30
        self.axes.set_ybound(lower=ymin, upper=ymax)
        self.axes.set_xlim(0, 20)
        self.axes.grid(True)

        FigCanvas.__init__(self, parent, -1, self.fig)
        self.drawing = False
开发者ID:klvt,项目名称:fiwt,代码行数:28,代码来源:dynamic_chart.py

示例13: EdgesCumulBarGraph

class EdgesCumulBarGraph(wx.Panel):
    ''' This panel holds edges cumulative bar graph. '''
    
    def __init__(self, parent):
        ''' parent is a fram instance. '''
        
        wx.Panel.__init__(self, parent = parent, id = -1)        
        self.figure = Figure(dpi = DPI, figsize = (8, 4)) 
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.axes = self.figure.add_subplot(111)
        # Labels
        self.axes.set_title("Cumulative Number of Major Edges per Interval")
        self.axes.set_ylabel("Cumulative number of edges")
        self.axes.set_xlabel("Intervals (%)")        
        # Sizers
        bSizer = wx.BoxSizer(wx.HORIZONTAL)
        bSizer.Add(self.canvas, 1, wx.EXPAND)
        self.SetSizer(bSizer)
        
        
    def DefineBarGraph(self, left, height):
        ''' Create bar graph. '''
        
        self.axes.bar(left = left, height = height, width = 5, bottom = 0, color = "b")
        
    
    def DrawBarGraph(self):
        ''' Draw the bar graph. '''
        
        self.canvas.draw()
开发者ID:jump3r,项目名称:LSA_APP_linux,代码行数:30,代码来源:GraphTools.py

示例14: CapacityPanel

class CapacityPanel(MyPanel):
    def __init__(self, *args, **kwargs):
        MyPanel.__init__(self, *args, **kwargs)        
        self.vbox = wx.BoxSizer(wx.VERTICAL)
        fig = Figure(facecolor=self.face_col)
        
        self.ax = fig.add_subplot(111)

        self.canvas = FigureCanvas(self, -1, fig)
        self.vbox.Add(self.canvas, flag = wx.EXPAND | wx.ALL)
        self.SetSizerAndFit(self.vbox)

        pub.subscribe(self.redraw, "assignments_calced")

    def redraw(self, message):
        """Create a histogram"""
        e_caps = self.model.excessCap()
        e_caps = [x * 100 for x in e_caps]

        self.ax.clear()
        n, bins, patches = self.ax.hist(e_caps, normed=False, bins=10, color="cornflowerblue", 
                    rwidth=.8, linewidth=0)
        self.ax.set_xlabel("Excess Capacity (%)")
        self.ax.set_ylabel("No. of Courses")
        self.ax.set_title("Distribution of Excess Capacity")
        
        num_courses = float(len(e_caps))
        s_labels = [ 100 * p.get_height()/num_courses for p in patches]
        s_labels = [ "%.0f%%" % p for p in s_labels]
        
        self.labelBars(patches, s_labels, self.ax)
        self.canvas.draw()
开发者ID:vgupta1,项目名称:ClassE,代码行数:32,代码来源:plotPanels.py

示例15: GraphPanel

class GraphPanel(wx.Panel):
    def __init__(self,parent):
        wx.Panel.__init__(self,parent)
        self.SetBackgroundColour('#FFFFFF')
        self.quote = wx.StaticText(self,label = "GRAPH PANEL", pos = (200,10))
        self.figure = Figure(dpi=100,figsize=(5,8))
        self.axes = self.figure.add_subplot(111)
        self.axes.axis([0,1,0,60])
        self.axes.set_ylabel('time (s)')
        green = self.axes.axhline(y=-1,color='g',lw=4)
        blue = self.axes.axhline(y=-1,color='b',lw=4)
        red = self.axes.axhline(y=-1,color='r',lw=4)
        self.axes.legend((green,blue,red),("Tone","Level Press","Reward"),loc="upper right")
        self.canvas = FigureCanvas(self, -1, self.figure)
        wx.EVT_PAINT(self, self.OnPaint)

    def OnPaint(self, event):
        self.canvas.draw()
        event.Skip()

    def OnSetFocus(self, event):
        #self.color = '#0099f7'
        self.color = 'yellow'
        self.Refresh()

    def OnKillFocus(self, event):
        self.color = '#b3b3b3'
        self.Refresh()
开发者ID:lrajmohan,项目名称:PyView,代码行数:28,代码来源:LeverPress_AWv1.2.py


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