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


Python FigureCanvasWxAgg.copy_from_bbox方法代码示例

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


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

示例1: mode_panel

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class mode_panel(wx.Panel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: mode_panel.__init__
        kwds["style"] = wx.TAB_TRAVERSAL
        wx.Panel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        
        self.figure = Figure(figsize=(6,4), dpi=80)
        self.axes_q = self.figure.add_subplot(211)
        self.axes_real_q = self.figure.add_subplot(212)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
        self.axes_q.set_autoscale_on(False)
        self.axes_q.set_xlim([0,100])
        self.axes_q.set_ylim([0,1])
        self.axes_q.set_xticks(range(0,101,100))        

        self.axes_real_q.set_autoscale_on(False)
        self.axes_real_q.set_xlim([0,100])
        self.axes_real_q.set_ylim([0,1])
        self.axes_real_q.set_xticks(range(0,101,5))
        self.axes_real_q.set_yticks(range(0,2,1))
        self.prob_q0 = [None] * 100
        self.prob_q1 = [None] * 100
        self.real_q = [None] * 100
        self.real_q_up2now = [None]*100
        
        self.q_file = open('dis_states')
        for i in range(100):
            self.real_q[i] = float(self.q_file.readline())
        self.q_file.close()
        self.l_prob_q0, = self.axes_q.plot(range(100), self.prob_q0, 'x', label='probability of mode 0') #plot return one element tuple
        self.l_prob_q1, = self.axes_q.plot(range(100), self.prob_q1, 'x', label='probability of mode 1')
        self.l_real_q, = self.axes_real_q.plot(range(100), self.real_q_up2now,'x')
        self.axes_q.legend(loc='upper center', ncol=2, prop=font_manager.FontProperties(size=10))
        self.axes_q.set_title('estimated probabilities of modes')
        self.axes_real_q.set_title('ture mode')
        self.axes_real_q.set_xlabel('time (s)')

        self.canvas.draw()
        self.bg_q = self.canvas.copy_from_bbox(self.axes_q.bbox)
        self.bg_real_q = self.canvas.copy_from_bbox(self.axes_real_q.bbox)

        
    def __set_properties(self):
        # begin wxGlade: mode_panel.__set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: mode_panel.__do_layout
        pass
开发者ID:delding,项目名称:dist-pf,代码行数:56,代码来源:Aux_IMMPF.py

示例2: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class PlotFigure(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, title="Sensor Monitor", size=(800, 600))
        #set window size
        self.fig = Figure((8, 6), 100)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig)
        self.ax = self.fig.add_subplot(111)
        self.ax.set_ylim([0, 100])
        self.ax.set_xlim([0, POINTS])
        self.ax.set_autoscale_on(False)
        self.ax.set_xticks([])
        self.ax.set_yticks(range(0, 101, 10))
        self.ax.grid(True)
        self.user = [None] * POINTS
        self.l_user,=self.ax.plot(range(POINTS),self.user,label='Light Sensors')
        self.ax.legend(loc='upper center',
                           ncol=4,
                           prop=font_manager.FontProperties(size=10))
        self.canvas.draw()
        self.bg = self.canvas.copy_from_bbox(self.ax.bbox)
        wx.EVT_TIMER(self, TIMER_ID, self.onTimer)

    def onTimer(self, evt):
        self.canvas.restore_region(self.bg)
        for i in range(0,240):
          index = int(i/40)*40
          per = (index-i)+20.0
          per =((math.sin((per/20.0)*math.pi/2))+1.0)/2.0
          self.user[i+30] = 100-(float(arr[i/40])*per+float(arr[(i+40)/40])*(1-per))*1
        self.l_user.set_ydata(self.user)
        self.ax.draw_artist(self.l_user)
        self.canvas.blit(self.ax.bbox)
开发者ID:xeecos,项目名称:LightMusic,代码行数:34,代码来源:show.py

示例3: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class PlotFigure(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, title="CPU Usage Monitor", size=(600, 400))
        # Matplotlib Figur
        self.fig = Figure((6, 4), 100)
        # bind the Figure to the backend specific canvas
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig)
        # add a subplot  
        self.ax = self.fig.add_subplot(111)
         # limit the X and Y axes dimensions 
        self.ax.set_ylim([0, 100])
        self.ax.set_xlim([0, POINTS])
         
        self.ax.set_autoscale_on(False)
        self.ax.set_xticks([])
        # we want a tick every 10 point on Y (101 is to have 10  
        self.ax.set_yticks(range(0, 101, 10))


        # disable autoscale, since we don't want the Axes to ad  
        # draw a grid (it will be only for Y)  
        self.ax.grid(True)  
        # generates first "empty" plots  
        self.user = [None] * POINTS  
        self.l_user,=self.ax.plot(range(POINTS),self.user,label='User %')  
    
        # add the legend  
        self.ax.legend(loc='upper center',  
                           ncol=4,  
                           prop=font_manager.FontProperties(size=10))  
        # force a draw on the canvas()  
         # trick to show the grid and the legend  
        self.canvas.draw()  
        # save the clean background - everything but the line  
        # is drawn and saved in the pixel buffer background  
        self.bg = self.canvas.copy_from_bbox(self.ax.bbox)  
        # bind events coming from timer with id = TIMER_ID  
        # to the onTimer callback function  
        wx.EVT_TIMER(self, TIMER_ID, self.onTimer)  
        self.Bind(wx.EVT_CLOSE,self.frame_close,self)
      
    def onTimer(self, evt):  
        self.canvas.restore_region(self.bg)  
                    # update the data  
        temp =np.random.randint(60,80)  
        self.user = self.user[1:] + [temp]  
            # update the plot  
        self.l_user.set_ydata(self.user)  
            # just draw the "animated" objects  
        self.ax.draw_artist(self.l_user)# It is used to efficiently update Axes data (axis ticks, labels, etc are not updated)  
        self.canvas.blit(self.ax.bbox) 
        print num
    
    def frame_close(self,event):
        self.Show(False)

    def __del__(self):
        exit()
开发者ID:NanguangChou,项目名称:numa_cpu,代码行数:60,代码来源:plottest.py

示例4: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class PlotFigure(wx.Frame):
    def __init__(self,data):
        wx.Frame.__init__(self, None, wx.ID_ANY, title="CPU Usage Monitor", size=(600, 400))
        # Matplotlib Figur
        self.fig = Figure((6, 4), 100)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig)
        # add a subplot  
        self.ax = self.fig.add_subplot(111)
        self.data=data;
        self.ax.set_ylim([0,100])
        self.ax.set_xlim([0, POINTS])
        
        self.ax.set_autoscale_on(False)
        self.ax.set_xticks([])
        self.ax.set_yticks(range(0,100, 5))


        # disable autoscale, since we don't want the Axes to ad  
        # draw a grid (it will be only for Y)  
        self.ax.grid(True)  
        # generates first "empty" plots  
        self.user = [None] * POINTS  
        self.l_user,=self.ax.plot(range(POINTS),self.user,label=u'CPU percentage')  
    
        # add the legend  
        self.ax.legend(loc='upper center',  
                           ncol=4,  
                           prop=font_manager.FontProperties(size=10))  
        self.canvas.draw()  
        self.bg = self.canvas.copy_from_bbox(self.ax.bbox)  
        wx.EVT_TIMER(self, TIMER_ID, self.onTimer)  
        self.Bind(wx.EVT_CLOSE,self.frame_close,self)
      
    def onTimer(self, evt):  
        self.canvas.restore_region(self.bg)
        temp = (math.log(self.data.recvive())/LOG_FREQUENCE)*100
        #temp =np.random.randint(60,80)  

        self.user = self.user[1:] + [temp]  
            # update the plot  
        self.l_user.set_ydata(self.user)  
            # just draw the "animated" objects  
        self.ax.draw_artist(self.l_user)# It is used to efficiently update Axes data (axis ticks, labels, etc are not updated)  
        self.canvas.blit(self.ax.bbox) 
        #print self.data.recvive()
    
    def frame_close(self,event):
        self.Show(False)

    def __del__(self):
        exit()
开发者ID:NanguangChou,项目名称:numa_cpu,代码行数:53,代码来源:my_cpu.py

示例5: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class PlotFigure (wx.Frame):
    
    def __init__ (self, groundTruth=None):
        wx.Frame.__init__ (self, None, wx.ID_ANY, title="Trajectory")
        
        self.fig = Figure ()
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig)
        self.ax = self.fig.add_subplot (111)
        self.ax.set_xlim ([-600, 1000])
        self.ax.set_ylim ([-1500, 1500])
        self.ax.set_autoscale_on (False)
        self.orbPos1 = None
        self.orbPos2 = None
        self.ax.grid(True)
        
        if groundTruth != None:
            grnd = groundTruth.toArray(False)
            self.groundPlot, = self.ax.plot (grnd[:,0], grnd[:,1])

        # This must be done after all initial drawing
        self.canvas.draw()
        self.bg = self.canvas.copy_from_bbox (self.ax.bbox)
        
        # Bind events to timer function
        wx.EVT_TIMER (self, TIMER_ID, self.onTimer)

    def onTimer (self, event):
        self.canvas.restore_region(self.bg)
        
        orbPosition1 = orbProc1.getPose()
        if orbPosition1 is not None:
            if self.orbPos1 is None:
                self.orbPos1 = self.ax.scatter (orbPosition1.x, orbPosition1.y, color=[[1,0,0,0.5]], s=100, linewidths=0)
            else :
                self.orbPos1.set_offsets([orbPosition1.x, orbPosition1.y])

        orbPosition2 = orbProc2.getPose()
        if orbPosition2 is not None:
            if self.orbPos2 is None:
                self.orbPos2 = self.ax.scatter (orbPosition2.x, orbPosition2.y, color=[[0,1,0,0.5]], s=100, linewidths=0)
            else :
                self.orbPos2.set_offsets([orbPosition2.x, orbPosition2.y])


        self.canvas.draw()
        self.canvas.blit(self.ax.bbox)
开发者ID:Aand1,项目名称:Autoware,代码行数:48,代码来源:TfVisualizer.py

示例6: DemoPanel1

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class DemoPanel1(wx.Panel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: DemoPanel1.__init__
        kwds["style"] = wx.TAB_TRAVERSAL
        wx.Panel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        self.figure = Figure(figsize=(6,4), dpi=80)
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
        self.axes.set_autoscale_on(False)
        self.axes.set_xlim([0,100])
        self.axes.set_ylim([-30,30])
        self.axes.set_xticks(range(0,101,5))
        self.axes.set_yticks(range(-30,31,5))
        self.exp_x = [None] * 100
        self.percentile_x_95 = [None] * 100
        self.percentile_x_5 = [None] * 100
        self.real_x = [None] * 100
        x_file = open('test_data_latent_state')
        for i in range(100):
            self.real_x[i] = float(x_file.readline())
        x_file.close()
        self.l_exp_x, = self.axes.plot(range(100), self.exp_x, label='mean') #plot return one element tuple
        self.l_real_x, = self.axes.plot(range(100), self.real_x, label='real value')
        self.l_percentile_x_95, = self.axes.plot(range(100), self.percentile_x_95, label='95% percentile')
        self.l_percentile_x_5, = self.axes.plot(range(100), self.percentile_x_5, label='5% percentile')
        self.axes.legend(loc='upper center', ncol=4, prop=font_manager.FontProperties(size=10))
        self.axes.set_title('latent state')
	self.axes.set_xlabel('time (s)')
        self.canvas.draw()
        self.bg = self.canvas.copy_from_bbox(self.axes.bbox)

    def __set_properties(self):
        # begin wxGlade: DemoPanel1.__set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: DemoPanel1.__do_layout
        pass
开发者ID:delding,项目名称:dist-pf,代码行数:45,代码来源:Demo_Erli.py

示例7: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class PlotFigure(wx.Frame):
    """Matplotlib wxFrame with animation effect"""
    def __init__(self):
        wx.Frame.__init__(self, None, wx.ID_ANY, title="CPU Usage Monitor", size=(600, 400))
        self.fig = Figure((6, 4), 100)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig)
        self.ax = self.fig.add_subplot(111)
        # limit the X and Y axes dimensions
        self.ax.set_ylim(2140, 2150)
        self.ax.set_xlim([0, POINTS])
        self.ax.set_autoscale_on(False)
        self.ax.set_xticks([])
        # we want a tick every 10 point on Y (101 is to have 10
        #self.ax.set_yticks(range(0, 101, 10))
        self.ax.grid(True)
        self.user = [None] * POINTS
        self.l_user,=self.ax.plot(range(POINTS),self.user,label=u'IF1406')

        self.md = MdThread("127.0.0.1",12345)
        self.md.start()
        self.md.RegTick(self.OnTick)
        # add the legend
        self.ax.legend(loc='upper center',
                           ncol=4,
                           prop=font_manager.FontProperties(size=10))
        self.canvas.draw()
        self.bg = self.canvas.copy_from_bbox(self.ax.bbox)
        #wx.EVT_TIMER(self, TIMER_ID, self.onTimer)

    def OnTick(self,tick):
        self.canvas.restore_region(self.bg)
                # update the data
        if tick.InstrumentID != 'IF1404':
            return
        print tick.LastPrice
        temp =np.random.randint(10,80)
        self.user = self.user[1:] + [tick.LastPrice]
        # update the plot
        self.l_user.set_ydata(self.user)
        # just draw the "animated" objects
        self.ax.draw_artist(self.l_user)# It is used to efficiently update Axes data (axis ticks, labels, etc are not updated)
        self.canvas.blit(self.ax.bbox)
开发者ID:norsd,项目名称:Yggdrasil,代码行数:44,代码来源:Monitor0.py

示例8: DemoPanel3

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class DemoPanel3(wx.Panel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: DemoPanel3.__init__
        kwds["style"] = wx.TAB_TRAVERSAL
        wx.Panel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade
        
        self.figure = Figure(figsize=(6,4), dpi=80)
        self.axes = self.figure.add_subplot(111)
        self.canvas = FigureCanvas(self, wx.ID_ANY, self.figure)
        self.axes.set_autoscale_on(False)
        self.axes.set_xlim([0,100])
        self.axes.set_ylim([-5,30])
        self.axes.set_xticks(range(0,101,5))
        self.axes.set_yticks(range(-5,31,5))
        self.data = [None] * 100
        self.data_up2_now = [None] * 100
        data_file = open('test_data')
        for i in range(100):
            self.data[i] = float(data_file.readline())
        data_file.close()
        self.axes.set_title('observations')
        self.axes.set_xlabel('time (s)')
        self.l_data, = self.axes.plot(range(100), self.data_up2_now, 'kx')
        self.bg = self.canvas.copy_from_bbox(self.axes.bbox)



    def __set_properties(self):
        # begin wxGlade: DemoPanel3.__set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: DemoPanel3.__do_layout
        pass
开发者ID:delding,项目名称:dist-pf,代码行数:41,代码来源:Demo_Erli.py

示例9: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class PlotFigure(wx.Frame):
	def __init__(self):
		wx.Frame.__init__(self,None,-1,"Cpu Status Monitor",size=(800,600))
		#button和label都建立在Panel上
		panel         = wx.Panel(self,-1) 
		#初始化label.输入框.按钮
		self.IPLabel       = wx.StaticText(panel,-1,"IP Address:")
		self.IPText        = wx.TextCtrl(panel,-1,"192.168.150.46",size=(100,-1))
		self.portLabel     = wx.StaticText(panel,-1,"Port:",)
		self.portText      = wx.TextCtrl(panel,-1,"9876",size=(100,-1))
		self.button        = wx.Button(panel,-1,"Start")
		self.button_record = False
		#初始化sizer对象
		sizer              = wx.FlexGridSizer(cols=5,hgap=6,vgap=6)
		sizer.AddMany([self.IPLabel,self.IPText,self.portLabel,self.portText,self.button])
		panel.SetSizer(sizer)
		#事件绑定
		self.Bind(wx.EVT_BUTTON,self.OnClick,self.button)
		#初始化canvas
		
		self.fig    = Figure((8,6),100)
		self.canvas = FigureCanvas(self,-1,self.fig)
		self.ax     = self.fig.add_subplot(221)
		self.ax.set_ylim([0,100])
		self.ax.set_xlim([0,POINTS])
		self.ax.set_autoscale_on(True)
		self.ax.set_xticks([])
		self.ax.set_yticks(range(0,101,10))
		self.ax.grid(True)
		self.user   = [None] * POINTS
		self.l_user,=self.ax.plot(range(POINTS),self.user,label="User %")
		self.ax.legend(loc='upper center',
							ncol=4,
							prop=font_manager.FontProperties(size=10))
		self.canvas.draw()
		self.bg     = self.canvas.copy_from_bbox(self.ax.bbox)
		
	def OnClick(self,event):
		exit()
开发者ID:NanguangChou,项目名称:numa_cpu,代码行数:41,代码来源:cpu_status.py

示例10: PanelGraph

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]

#.........这里部分代码省略.........
        self.measureTable.show(self.settings.showMeasure)
        self.panel.SetFocus()

    def set_fonts(self):
        axes = self.plot.get_axes()
        axes.xaxis.label.set_size('small')
        axes.yaxis.label.set_size('small')
        if self.settings.display == Display.SURFACE:
            axes.zaxis.label.set_size('small')
        axes.tick_params(axis='both', which='major', labelsize='small')
        axes = self.plot.get_axes_bar()
        axes.tick_params(axis='both', which='major', labelsize='small')

    def add_menu_clear_select(self, menu):
        self.menuClearSelect.append(menu)
        menu.Enable(False)

    def enable_menu(self, state):
        for menu in self.menuClearSelect:
            menu.Enable(state)

    def on_size(self, event):
        ppi = wx.ScreenDC().GetPPI()
        size = [float(v) for v in self.canvas.GetSize()]
        width = size[0] / ppi[0]
        height = size[1] / ppi[1]
        self.figure.set_figwidth(width)
        self.figure.set_figheight(height)
        self.figure.set_dpi(ppi[0])
        event.Skip()

    def on_draw(self, _event):
        axes = self.plot.get_axes()
        self.background = self.canvas.copy_from_bbox(axes.bbox)
        self.draw_overlay()

    def on_select(self):
        self.hide_measure()

    def on_selected(self, start, end):
        self.enable_menu(True)
        self.selectStart = start
        self.selectEnd = end
        self.measureTable.set_selected(self.spectrum, start, end)

    def on_idle(self, _event):
        if self.doDraw and self.plot.get_plot_thread() is None:
            self.hide_overlay()
            self.canvas.draw()
            self.doDraw = False

    def on_timer(self, _event):
        self.timer.Stop()
        self.set_plot(None, None, None, None, self.annotate)

    def draw(self):
        self.doDraw = True

    def show_measureTable(self, show):
        self.measureTable.show(show)
        self.Layout()

    def set_plot(self, spectrum, isLimited, limit, extent, annotate=False):
        if spectrum is not None and extent is not None:
            if isLimited is not None and limit is not None:
                self.spectrum = copy.copy(spectrum)
开发者ID:BloodyCool,项目名称:RTLSDR-Scanner,代码行数:70,代码来源:windows.py

示例11: MyPlot

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]

#.........这里部分代码省略.........
        self.ax.grid()
        #self.fig.clear()
        
        self.canvas.draw()        
        self.background = None
        print 'content'
        self._doRePlot = False
        
        
    def _createGraphics(self):
        """Reallocate new figure and take care of panel resizing issues"""
        self.fig=Figure()
        self.canvas=FigureCanvas(self,-1,self.fig)
        self.ax = self.fig.add_subplot(111)
        
        self.ax._cachedRenderer=self.canvas.get_renderer()
        
    def _onSize(self, evt):
        self._resizeFlag = True
        
    def _onIdle(self, event):
        event.RequestMore(True)
        if self._resizeFlag:
            self._resizeFlag = False
            self._SetSize()
        self.draw_plot()
        #if self.foo > 2000:
            #u=time.time()
            #print self.foo/(u-self.t), self.blit_time/(u-self.t)
            #exit(0)

    def _SetSize(self, pixels=None):
        if not pixels:
            pixels = self.GetClientSize()
        self._createGraphics()
        self.canvas.SetSize(pixels)
        
        self.fig.set_size_inches(pixels[0]/self.fig.get_dpi(),
        pixels[1]/self.fig.get_dpi(), forward=True)
        self._doRePlot = True
       
    def draw_plot(self):
                if self._doRePlot:
                    self._resizeCreateContent()
                if self.background is None:
                    self.background = self.canvas.copy_from_bbox(self.ax.bbox)
                self.foo += 1
                #self.y = numpy.cos(numpy.arange(0.0,1.0,0.1)+self.foo*0.1)
                # Optimization on the blitting: we compute the box where the changes happen
                changes_box = None

                for i in range(len(self.lines)):
                    data=self.channels[i].getNext()
                    
                    if len(data[1])>0:
                        if self.autolim:
                            print self.autolim[0], data[1], self.autolim[1]
                            self.autolim = [ min(self.autolim[0], min(data[1])), \
                                max(self.autolim[1], max(data[1])) ]
                        else:
                            self.autolim = [ min(data[1]), min(data[1]) ]
                        
                        if changes_box is None:
                            changes_box = Bbox.unit()
                        print '>>>>>>>>'
                        print data[0], data[1]
                        changes_box.update_from_data(numpy.array(data[0]), \
                                numpy.array(data[1]), ignore=changes_box.is_unit())
                        
                        if not self._doRePlot and len(data[0]) > 0 :
                            end = data[0][-1]
                            
                            if end > self.begin+self.span:
                                self.begin += self.span
                                self._doRePlot = True
                                print 'do replot'
                        self.lines[i].set_data(data[0], data[1])
                    else:
                        self.lines[i].set_data([], [])
                
                if not changes_box:
                    return
                #self.canvas.restore_region(self.background)
                for line in self.lines:
                    self.ax.draw_artist(line)
                    #print line.get_transform()
                    tr = line.get_transform()
                    
                changes_box_inframe = changes_box.transformed(tr)
                
                box_padding = 5
                (x,y,l,w) = changes_box_inframe.bounds
                changes_box_inframe = Bbox.from_bounds(x-box_padding, \
                    y-box_padding, l+2*box_padding, w+2*box_padding)
                
                #print 
                t0 = time.time()
                self.canvas.blit(None)
                #self.canvas.blit(changes_box_inframe)
                self.blit_time += time.time() - t0
开发者ID:janfrs,项目名称:kwc-ros-pkg,代码行数:104,代码来源:myplot.py

示例12: MPL_Panel_base

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]
class MPL_Panel_base(wx.Panel):
    ''' #MPL_Panel_base面板,可以继承或者创建实例'''
    def __init__(self,parent):
        wx.Panel.__init__(self,parent=parent, id=-1)

        self.Figure = matplotlib.figure.Figure(figsize=(8,6))
        self.axes = self.Figure.add_axes([0.1,0.1,0.8,0.8])
        self.FigureCanvas = FigureCanvas(self,-1,self.Figure)
        
        self.NavigationToolbar = NavigationToolbar(self.FigureCanvas)

        self.StaticText = wx.StaticText(self,-1,label='Show Help String')

        self.SubBoxSizer = wx.BoxSizer(wx.HORIZONTAL)
        self.SubBoxSizer.Add(self.NavigationToolbar,proportion =0, border = 2,flag = wx.ALL | wx.EXPAND)
        self.SubBoxSizer.Add(self.StaticText,proportion =-1, border = 2,flag = wx.ALL | wx.EXPAND)

        self.TopBoxSizer = wx.BoxSizer(wx.VERTICAL)
        self.TopBoxSizer.Add(self.SubBoxSizer,proportion =-1, border = 2,flag = wx.ALL | wx.EXPAND)
        self.TopBoxSizer.Add(self.FigureCanvas,proportion =-10, border = 2,flag = wx.ALL | wx.EXPAND)

        self.SetSizer(self.TopBoxSizer)

        ###方便调用
        self.pylab=pylab
        self.pl=pylab
        self.pyplot=pyplot
        self.numpy=np
        self.np=np
        self.plt=pyplot
        
        self.bg = self.FigureCanvas.copy_from_bbox(self.axes.bbox)
        #self.xticker()
        self.axes.set_autoscale_on(False)
        
        self.xlim(0,POINTS)
        self.ylim(0,100)

    def UpdatePlot(self):
        '''#修改图形的任何属性后都必须使用self.UpdatePlot()更新GUI界面 '''
        self.grid(True)

        self.xlim(0,POINTS)
        self.ylim(0,100)
        self.FigureCanvas.draw()


    def plot(self,*args,**kwargs):
        '''#最常用的绘图命令plot '''
        self.axes.plot(*args,**kwargs)
        self.UpdatePlot()


    def semilogx(self,*args,**kwargs):
        ''' #对数坐标绘图命令 '''
        self.axes.semilogx(*args,**kwargs)
        self.UpdatePlot()

    def semilogy(self,*args,**kwargs):
        ''' #对数坐标绘图命令 '''
        self.axes.semilogy(*args,**kwargs)
        self.UpdatePlot()

    def loglog(self,*args,**kwargs):
        ''' #对数坐标绘图命令 '''
        self.axes.loglog(*args,**kwargs)
        self.UpdatePlot()


    def grid(self,flag=True):
        ''' ##显示网格  '''
        if flag:
            self.axes.grid()
        else:
            self.axes.grid(False)


    def title_MPL(self,TitleString="wxMatPlotLib Example In wxPython"):
        ''' # 给图像添加一个标题   '''
        self.axes.set_title(TitleString)


    def xlabel(self,XabelString="X"):
        ''' # Add xlabel to the plotting    '''
        self.axes.set_xlabel(XabelString)


    def ylabel(self,YabelString="Y"):
        ''' # Add ylabel to the plotting '''
        self.axes.set_ylabel(YabelString)


    def xticker(self,major_ticker=5,minor_ticker=5):
        ''' # 设置X轴的刻度大小 '''
        self.axes.xaxis.set_major_locator( MultipleLocator(major_ticker) )
        self.axes.xaxis.set_minor_locator( MultipleLocator(minor_ticker) )


    def yticker(self,major_ticker=5,minor_ticker=5):
        ''' # 设置Y轴的刻度大小 '''
#.........这里部分代码省略.........
开发者ID:NanguangChou,项目名称:numa_cpu,代码行数:103,代码来源:MPL_test.py

示例13: PlotFigure

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]

#.........这里部分代码省略.........
        self.power8_accumulate_value = 0
        self.x86_accumulate_value = 0
        self.power8_previous_value = 0
        self.x86_previous_value = 0

        self.power8_ave_index = [3]
        self.x86_ave_index = [1]
        self.power8_ave_value = [0]
        self.x86_ave_value = [0]
        self.power8_barh, = self.average.barh(bottom=self.power8_ave_index,
                width=self.power8_ave_value, height=1.0,
                color='red', label='CP1 TPC-C (Average)')
        self.x86_barh, = self.average.barh(bottom=self.x86_ave_index,
                width=self.x86_ave_value, height=1.0,
                color='green', label="X86 TPC-C (Average)")

        self.average.grid(True)
        self.average.legend(loc='upper center', ncol=4,
                prop=font_manager.FontProperties(size=16)
                #prop=font_manager.FontProperties(size=10)
                )
        self.average.set_yticks([])

        self.fig.subplots_adjust(left=0.08, right=0.95, bottom=0.05, top=0.95)

        ##########################################################################################

        # TODO: resize the subplot in figure
        self.ax.set_position([0.08, 0.40, 0.85, 0.55])
        self.average.set_position([0.08, 0.05, 0.85, 0.28])

        self.canvas.draw()
        # save the clean background
        self.background_1st = self.canvas.copy_from_bbox(self.ax.bbox)
        self.background_2nd = self.canvas.copy_from_bbox(self.average.bbox)

        self.global_timer_index = 0
        self.local_timer_index = 0
        self.power8_current_all_values = []
        self.x86_current_all_values = []

        wx.EVT_TIMER(self, TIMER_ID, self.on_timer)

    def on_timer(self, event):
        # restore the clean background, saved at the beginning
        self.canvas.restore_region(self.background_1st)
        self.canvas.restore_region(self.background_2nd)

        #copyfile(power8_source_filename, power8_input_filename)
        #copyfile(x86_source_filename, x86_input_filename)
        #print(time.strftime("%s"))

        self.global_timer_index += 1
        self.local_timer_index += 1

        line_index = self.global_timer_index - 1
        less_number = EMPTY_NUMBER - self.local_timer_index
        needed_number = self.local_timer_index - 1

        # get the value of current index from file
        power8_current_value = self.read_from_file_by_index(
                power8_input_filename, line_index)
        x86_current_value = self.read_from_file_by_index(
                x86_input_filename, line_index)

        # normal return: accumulate the return value directly.
开发者ID:MingquanLiang,项目名称:oftenusedscript,代码行数:70,代码来源:display_TPCC-Performance_CP1_vs_X86_20151202_v2.py

示例14: CirclePanel

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]

#.........这里部分代码省略.........
    #update the title, which shows the equation of the circle
    def UpdateTitle(self):
        titleText = "$(x{h})^2 + (y{k})^2 = {r}^2$"
        titleH, titleK, titleR = "-0.0", "-0.0", round(self.r, 2)

        #format signs correctly
        if self.h < 0.0:
            titleH = "+{val}".format(val=abs(round(self.h, 2)))
        elif self.h > 0.0:
            titleH = "-{val}".format(val=abs(round(self.h, 2)))
        if self.k < 0.0:
            titleK = "+{val}".format(val=abs(round(self.k, 2)))
        elif self.k > 0.0:
            titleK = "-{val}".format(val=abs(round(self.k, 2)))

        #show the students that they can omit h or k in the equation if it equals 0.0
        if self.h == 0.0 and not self.k == 0.0:
            titleText = titleText + " OR $x^2 + (y{k})^2 = {r}^2$"
        elif not self.h == 0.0 and self.k == 0.0:
            titleText = titleText + " OR $(x{h})^2 + y^2 = {r}^2$"
        elif self.h == 0.0 and self.k == 0.0:
            titleText = titleText + " OR $x^2 + y^2 = {r}^2$"

        self.subplot.set_title(titleText.format(h=titleH, k=titleK, r=titleR),
            fontproperties=mpl.font_manager.FontProperties(size="x-large"))

    #draw/redraw the canvas
    def DrawFigure(self):
        self.subplot.clear()

        #set the "window" of the plot
        self.subplot.set_ylim([-5, 5])
        self.subplot.set_xlim([-5, 5])

        #draw grid and axes lines
        self.subplot.grid(True)
        self.subplot.axhspan(0, 0)
        self.subplot.axvspan(0, 0)

        self.UpdateTitle()

        #draw the circles
        circleColor = (0, 0, 1, 1)
        #must multiply r by 2 b/c Arc takes the length (diameter) of the axes, not the radius

        #circle1 is the reference circle (red)
        """
        circle1 = patches.Arc((0, 0), 2, 2, edgecolor="#FF0000", alpha=0.8)
        self.subplot.plot([0.0, 1.0], [0.0, 0.0], marker="o", color="#FF0000", mec="#FF0000", mfc="#FF0000")
        self.subplot.add_patch(circle1)
        """

        #circle2 is the user-manipulated circle (blue)
        self.circle = patches.Arc((self.h, self.k), self.r*2, self.r*2, edgecolor=circleColor, alpha=0.8)
        self.points = self.subplot.plot([self.h, self.h+self.r], [self.k, self.k], marker="o", picker=5, color=circleColor, mec=circleColor, mfc=circleColor)
        #get the first (and only) line, not the list
        self.points = self.points[0]
        self.subplot.add_patch(self.circle)

        self.canvas.draw()

    def UpdateFigure(self):
        #update data
        self.circle.center = (self.h, self.k)
        self.circle.width = 2*self.r
        self.circle.height = 2*self.r
        self.points.set_xdata([self.h, self.h+self.r])
        self.points.set_ydata([self.k, self.k])
        self.UpdateTitle()

        #draw
        self.canvas.restore_region(self.background)
        self.subplot.draw_artist(self.subplot.title)
        self.subplot.draw_artist(self.circle)
        self.subplot.draw_artist(self.points)
        self.canvas.blit(self.figure.bbox)

    def SaveBackground(self):
        self.circle.set_animated(True)
        self.points.set_animated(True)

        #clear plot
        self.subplot.set_title(" ")
        self.canvas.draw()

        #save figure
        self.background = self.canvas.copy_from_bbox(self.figure.bbox)

        self.UpdateTitle()

        #blit figures back onto the plot
        self.subplot.draw_artist(self.circle)
        self.subplot.draw_artist(self.points)
        self.subplot.draw_artist(self.subplot.title)
        self.canvas.blit(self.figure.bbox)

    def SetParameters(self, h, k, r):
        self.h = h
        self.k = k
        self.r = r
开发者ID:rolph-recto,项目名称:Circles,代码行数:104,代码来源:circles.py

示例15: PanelGraph

# 需要导入模块: from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg [as 别名]
# 或者: from matplotlib.backends.backend_wxagg.FigureCanvasWxAgg import copy_from_bbox [as 别名]

#.........这里部分代码省略.........
        markers.extend(find_artists(self.figure, 'peakThres'))
        hit = False
        for marker in markers:
            if isinstance(marker, Line2D):
                location = marker.get_path().vertices[0]
                markX, markY = axes.transData.transform(location)
                dist = abs(math.hypot(event.x - markX, event.y - markY))
                if dist <= 5:
                    if self.settings.display == Display.PLOT:
                        tip = "{}, {}".format(*format_precision(self.settings,
                                                                location[0],
                                                                location[1]))
                    else:
                        tip = "{}".format(format_precision(self.settings,
                                                           location[0]))
                    self.toolTip.SetTip(tip)
                    hit = True
                    break
        self.toolTip.Enable(hit)

    def __on_size(self, event):
        ppi = wx.ScreenDC().GetPPI()
        size = [float(v) for v in self.canvas.GetSize()]
        width = size[0] / ppi[0]
        height = size[1] / ppi[1]
        self.figure.set_figwidth(width)
        self.figure.set_figheight(height)
        self.figure.set_dpi(ppi[0])
        event.Skip()

    def __on_draw(self, _event):
        axes = self.plot.get_axes()
        if axes is not None:
            self.background = self.canvas.copy_from_bbox(axes.bbox)
            self.__draw_overlay()

    def __on_idle(self, _event):
        if self.doDraw and self.plot.get_plot_thread() is None:
            self.__hide_overlay()
            self.doDraw = False
            if os.name == 'nt':
                threading.Thread(target=self.__draw_canvas, name='Draw').start()
            else:
                with self.lockDraw:
                    self.canvas.draw()
                self.status.set_busy(False)

    def __on_timer(self, _event):
        self.timer.Stop()
        self.set_plot(None, None, None, None, self.annotate)

    def __draw_canvas(self):
        with self.lockDraw:
            try:
                self.canvas.draw()
            except wx.PyDeadObjectError:
                pass
        wx.CallAfter(self.status.set_busy, False)

    def __draw_overlay(self):
        if self.background is not None:
            self.canvas.restore_region(self.background)
            self.__draw_select()
            self.draw_measure()
            axes = self.plot.get_axes()
            if axes is None:
开发者ID:har5ha,项目名称:RTLSDR-Scanner,代码行数:70,代码来源:panels.py


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