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


Python FigureCanvasTkAgg.draw方法代码示例

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


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

示例1: MonitorWindow

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class MonitorWindow(PanedWindow):
    def __init__(self, master, skeleton):
        PanedWindow.__init__(self, master=master, height=400)
        self.skeleton = skeleton

        self.figure = Figure(figsize=(5,4), dpi=100)

        self.subplots = {}

        nrows = len(self.skeleton.units)
        ncols = 3
        plot_counter = 1

        for u in self.skeleton.units.keys():
            subplots = [None, None, None]
            history = self.skeleton.units[u].history()
            t = range(0, len(history[0]))

            for a in range(0, 3):
                subplot = self.figure.add_subplot(nrows, ncols, plot_counter, xlim=[0,200], ylim=[-90,90])
                s = history[a]
                subplot.plot(t,s)
                plot_counter += 1
                subplots[a] = subplot

            self.subplots[u] = subplots

        self.canvas = FigureCanvasTkAgg(self.figure, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side="top", fill="both", expand=1)

        self.canvas.mpl_connect("key_press_event", self.pressed_key)

        self.pack(fill="both", expand="yes")

    def redraw_graph(self):
        plot_counter = 1

        for k, axes in self.subplots.iteritems():
            history = self.skeleton.units[k].history()
            t = range(0, len(history[0]))

            for a, subplot in enumerate(axes):
                s = history[a]
                subplot.plot(t,s)
                plot_counter += 1

                subplot.clear()
                subplot.plot(t,s)

                subplot.set_xlim([0, 200])
                subplot.set_ylim([-90, 90])

        self.canvas.draw()

    def pressed_key(self, event):
        if event.key == "r":
            self.redraw_graph()
        else:
            print("Key pressed: %s" % event.key)
开发者ID:bnhymn,项目名称:jester,代码行数:62,代码来源:monitor.py

示例2: build_graph

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
    def build_graph(self):
        """ Update the plot area with loss values and cycle through to
        animate """
        self.ax1.set_xlabel('Iterations')
        self.ax1.set_ylabel('Loss')
        self.ax1.set_ylim(0.00, 0.01)
        self.ax1.set_xlim(0, 1)

        losslbls = [lbl.replace('_', ' ').title() for lbl in self.losskeys]
        for idx, linecol in enumerate(['blue', 'red']):
            self.losslines.extend(self.ax1.plot(0, 0,
                                                color=linecol,
                                                linewidth=1,
                                                label=losslbls[idx]))
        for idx, linecol in enumerate(['navy', 'firebrick']):
            lbl = losslbls[idx]
            lbl = 'Trend{}'.format(lbl[lbl.rfind(' '):])
            self.trndlines.extend(self.ax1.plot(0, 0,
                                                color=linecol,
                                                linewidth=2,
                                                label=lbl))

        self.ax1.legend(loc='upper right')

        plt.subplots_adjust(left=0.075, bottom=0.075, right=0.95, top=0.95,
                            wspace=0.2, hspace=0.2)

        plotcanvas = FigureCanvasTkAgg(self.fig, self.frame)
        plotcanvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        ani = animation.FuncAnimation(self.fig, self.animate, interval=2000, blit=False)
        plotcanvas.draw()
开发者ID:huangjiancong1,项目名称:faceswap-huang,代码行数:33,代码来源:gui.py

示例3: LcdPlot

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class LcdPlot( object ):

	def __init__( self, rfe, frame ):
		self.rfe = rfe
		self.frame = frame
		self.lcd_data = self.rfe.lcd_data

		self.figure_lcd = mpl.figure.Figure( figsize=(2,1), dpi=100, frameon=False )
		self.canvas_lcd = FigureCanvasTkAgg( self.figure_lcd, master=self.frame )
		self.lcd_subplot = self.figure_lcd.add_subplot( '111' )

		# style figure
		self.figure_lcd.patch.set_alpha( 0.0 ) # makes background patch invisible
		self.figure_lcd.patch.set_visible( False )

		# style lcd
		self.lcd_subplot.set_axis_off() # will show graph only, rest is transparent

		self.img = self.lcd_subplot.matshow( np.random.random((64*2, 128*2)), cmap='Greys' ) # why does only random work, not zeros or ones?

		#self.figure_lcd.tight_layout()
		self.canvas_lcd.show()
		self.canvas_lcd.get_tk_widget().grid()

	def update( self ):
		if not self.lcd_data.empty():
			while not self.lcd_data.empty():
				lcd = self.lcd_data.get()
			lcd = np.kron( lcd, np.ones((2,2)) ) # scale by factor 2
			self.img.set_array( lcd )
			self.canvas_lcd.draw()
开发者ID:RFExplorer,项目名称:pyRFExplorer,代码行数:33,代码来源:plot.py

示例4: DCanvas

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class DCanvas(ttk.Frame):
    '''Drawing the dynamic canvas, as weel as the parspace generator'''
    fig = matplotlib.figure.Figure()
    fig_ld = {}

    def __init__(self, master=None, par=None):
        ttk.Frame.__init__(self, master)
        self.pack()
     #   fig.add_subplot(212)
        self.canvas = FigureCanvasTkAgg(self.fig, master=self.master)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side='top', fill='both', expand=1)
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.master)
        self.toolbar.update()

    def draw_parspace(self, par=None, s=None):
        x = par.pars_axs[s][0]
        y = par.pars_axs[s][1]
        print x, y
        #try:
            #self.fig = self.fig_ld[s].frozen()
            #print s
        #except KeyError:
            #self.fig_ld[s] = matplotlib.figure.Figure()
        for i in range(0, x * y):
          #  self.fig_ld[s].add_subplot(x, y, i + 1)
            self.fig.add_subplot(x, y, i + 1)
            print i
        #self.fig = self.fig_ld[s].frozen()
        self.canvas.draw()
开发者ID:Jerry-Ma,项目名称:galaxev-dev,代码行数:32,代码来源:draw.py

示例5: __init__

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class tk_plot:
    def __init__(self,master,row=0,col=0,rowspan=1,colspan=1,size=(6,6),dpi=100,interval=1000):
        self.xdata = []
        self.ydata = []
        self.fig = Figure(figsize=size, dpi=dpi)
        self.ax = self.fig.add_subplot(111)
        self.ax.plot(self.xdata,self.ydata)
        self.canvas = FigureCanvasTkAgg(self.fig, master = master)
        self.canvas.draw()
        self.canvas.get_tk_widget().grid(row=row,column=col,rowspan=rowspan,columnspan=colspan,sticky=tk.N+tk.S+tk.E+tk.W)
        self.ani = animation.FuncAnimation(self.fig, self.plot_loop , interval=interval)

    def plot_loop(self,i):
        self.ax.plot(self.xdata, self.ydata)

    def add_data(self,x,y):
        self.xdata.append(float(x))
        self.ydata.append(float(y))

    def get_tk_widget(self):
        return self.canvas.get_tk_widget()

    def get_x_data(self):
        return self.xdata

    def get_y_data(self):
        return self.ydata
开发者ID:onionys,项目名称:python_code,代码行数:29,代码来源:tk_plot.py

示例6: plot

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
def plot(window_array):
	#setting preview window parameter
	window_preview = int(preview_time.get()) #in no of data pointa at 50kHz

	import matplotlib.pyplot as plt
	from matplotlib.figure import Figure
	from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg

	fig = Figure(figsize=(18,4), dpi=100)
	a = fig.add_subplot(111)
	
	a.plot(window_array[:window_preview,0], window_array[:window_preview,1], 'k-', label='Trace')
	a.plot(window_array[:window_preview,0], window_array[:window_preview,2], 'r-', label='Baseline Average')
	a.set_ylim(min(window_array[100:window_preview,1]), max(window_array[100:window_preview,1]))
	
	a.set_xlabel('Time (s)')
	a.set_ylabel('current (nA)')
	a.legend(loc='best')
	


	dataPlot = FigureCanvasTkAgg(fig, master=f5i)
	dataPlot.draw()	
	dataPlot.show()
	dataPlot.get_tk_widget().pack(side=TOP)
开发者ID:kaiwhata,项目名称:qNano,代码行数:27,代码来源:irbd_process_v4.py

示例7: __init__

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class App:
    def __init__(self, master):
        # Create a container
        frame = tkinter.Frame(master)
        # Create 2 buttons
        self.button_left = tkinter.Button(frame, text="< Decrease Slope", command=self.decrease)
        self.button_left.pack(side="left")
        self.button_right = tkinter.Button(frame, text="Increase Slope >", command=self.increase)
        self.button_right.pack(side="left")

        fig = Figure()
        ax = fig.add_subplot(111)
        self.line, = ax.plot([x / 0.5 for x in range(20)])
        self.canvas = FigureCanvasTkAgg(fig, master=master)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side="top", fill="both", expand=1)
        frame.pack()

    def decrease(self):
        x, y = self.line.get_data()
        self.line.set_ydata(y + [cos(xx) for xx in x])
        self.canvas.draw()

    def increase(self):
        x, y = self.line.get_data()
        self.line.set_ydata(y + 0.2 * x)
        self.canvas.draw()
开发者ID:PaulAntonucci,项目名称:python,代码行数:29,代码来源:Interactive+GraphExaample.py

示例8: __init__

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class App:
    def __init__(self, master, figure):
        # Create a container
        frame = tkinter.Frame(master)
        # Create 2 buttons
        self.button_left = tkinter.Button(frame, text="< Decrease Slope",
                                          command=self.decrease)
        self.button_left.pack(side="left")
        self.button_right = tkinter.Button(frame, text="Increase Slope >",
                                           command=self.increase)
        self.button_right.pack(side="left")

        # fig = Figure()
        ax = figure.add_subplot(212)
        self.line, = ax.plot(range(10))

        self.canvas = FigureCanvasTkAgg(figure, master=master)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side='top', fill='both', expand=1)
        frame.pack()

    def decrease(self):
        x, y = self.line.get_data()
        self.line.set_ydata(y - 0.2 * x)
        self.canvas.draw()

    def increase(self):
        x, y = self.line.get_data()
        self.line.set_ydata(y + 0.2 * x)
        self.canvas.draw()
开发者ID:franciscoSoler,项目名称:mini,代码行数:32,代码来源:hstack_example.py

示例9: __init__

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class PlotFrame:
    def __init__(self, parent):
        self.parent = parent
        # TOP FRAME - CANVAS
        self.f = plt.figure(figsize=(5, 5))
        self.a = self.f.add_subplot(111)
        self.a.grid(True)
        #self.a.set_xlabel(self.description)
        self.a.set_ylabel("Probability")
        self.canvas = FigureCanvasTkAgg(self.f, master=parent)
        self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
        self.canvas._tkcanvas.pack(side='top', fill='both', expand=1)

    def update(self):
        self.canvas.draw()

    def get_plot(self):
        return self.a

    def plot(self, ext):
        from tkFileDialog import asksaveasfilename
        name = 'puq-plot'
        filename = asksaveasfilename(title="Plot to file...",
                                     initialfile=name,
                                     defaultextension='.%s' % ext,
                                     filetypes=[(ext.upper(), '*.%s' % ext)])
        if not filename:
            return
        self.canvas.print_figure(filename)
开发者ID:zoidy,项目名称:puq,代码行数:31,代码来源:read.py

示例10: TelescopeEventView

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class TelescopeEventView(tk.Frame, object):
    """ A frame showing the camera view of a single telescope """

    def __init__(self, root, telescope, data=None, *args, **kwargs):
        self.telescope = telescope
        super(TelescopeEventView, self).__init__(root)
        self.figure = Figure(figsize=(5, 5), facecolor='none')
        self.ax = Axes(self.figure, [0, 0, 1, 1], aspect=1)
        self.ax.set_axis_off()
        self.figure.add_axes(self.ax)
        self.camera_plot = CameraPlot(telescope, self.ax, data, *args, **kwargs)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
        self.canvas._tkcanvas.pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
        self.canvas._tkcanvas.config(highlightthickness=0)

    @property
    def data(self):
        return self.camera_plot.data

    @data.setter
    def data(self, value):
        self.camera_plot.data = value
        self.canvas.draw()
开发者ID:MaxNoe,项目名称:cta_event_viewer,代码行数:27,代码来源:__init__.py

示例11: TkSimulationWindow

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class TkSimulationWindow(object):
    def __init__(self, root):
        self.root = root
        self._init_app()

        # here we embed the a figure in the Tk GUI

    def _init_app(self):
        self.figure = mpl.figure.Figure()
        self.ax = self.figure.add_subplot(111)
        self.canvas = FigureCanvasTkAgg(self.figure, self.root)
        self.toolbar = TkSimulationToolbar(self.canvas, self.root)
        self.toolbar.update()
        self.plot_widget = self.canvas.get_tk_widget()
        self.plot_widget.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self.toolbar.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self.canvas.show()

        # plot something random

    def plot(self):
        # 		self.axes.hold(False)
        t = arange(0.0, 3.0, 0.01)
        s = sin(2 * pi * t)

        self.canvas.draw()
开发者ID:gabrielantao,项目名称:hydraulics-project,代码行数:28,代码来源:tksimulationwindow.py

示例12: cria_grafi_cqi

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
    def cria_grafi_cqi(self):
        global lista_cqi, flag_plot_cqi, flag_stop, x_linha
        fig2 = pylab.figure(2)
        ax2 = fig2.add_axes([0.1,0.1,0.8,0.8])
        ax2.grid(True)
        ax2.set_title("RealTime plot FAPI - CQI INDICATION")
        ax2.set_xlabel("Time")
        ax2.set_ylabel("Amplitude")
        ax2.axis([0,1000,0,100])
        line2, = pylab.plot(lista_cqi)

        canvas2 = FigureCanvasTkAgg(fig2, master=self.parent)
        canvas2.get_tk_widget().pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        canvas2.show()
        toolbar2 = NavigationToolbar2TkAgg( canvas2, self.parent)
        toolbar2.update()
        canvas2._tkcanvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        ########################################################################
        #                         Geracao do grafico                           #
        ########################################################################
        while flag_stop == False:

            delete_cqi()
            lista_cqi.extendleft(valor_plot_cqi)
            line2.set_ydata(lista_cqi)
            canvas2.draw()
开发者ID:IrvinRaneki,项目名称:CPqD-GSF,代码行数:28,代码来源:fapi_analyzer_completo.py

示例13: RSSIPlot

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
class RSSIPlot(object):

    def __init__(self, device_mac):
        self.device_mac = device_mac
        self.receiver_plots = dict()

        self.window = Tk.Toplevel()

        self.figure = Figure()
        self.canvas = FigureCanvasTkAgg(self.figure, master=self.window)
        self.canvas.draw()
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        
        

    def plot_point(self, packet):
        if not packet.receiver_mac in self.receiver_plots:
            i = len(self.receiver_plots) + 1
            ax = self.figure.add_subplot(7, 1, i)
            line, = ax.plot(range(10), range(10), animated=True, lw=2)
            self.receiver_plots[packet.receiver_mac] = (ax, line, [], [])
            self.canvas.draw()

        ax, line, xdata, ydata = self.receiver_plots[packet.receiver_mac]
        xdata.append(packet.timestamp[0])
        ydata.append(packet.rssi)
        line.set_data(xdata, ydata)

        #ax.draw_artist(line)
        self.figure.canvas.blit(ax.bbox)
开发者ID:greenest,项目名称:BTScan,代码行数:32,代码来源:rssi_plot.py

示例14: cria_grafi

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
    def cria_grafi(self):
        global lista, flag, x, flag_stop

        ########################################################################
        #                     Criacao do Grafico e Tollbar                     #
        ########################################################################
        fig = pylab.figure(1)
        ax = fig.add_axes([0.1,0.1,0.8,0.8])
        ax.grid(True)
        ax.set_title("RealTime plot FAPI - CQI INDICATION")
        ax.set_xlabel("Time")
        ax.set_ylabel("Amplitude")
        ax.axis([0,1000,0,100])
        line, = pylab.plot(lista)

        canvas = FigureCanvasTkAgg(fig, master=self.parent)
        canvas.get_tk_widget().pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        canvas.show()
        toolbar = NavigationToolbar2TkAgg( canvas, self.parent )
        toolbar.update()
        canvas._tkcanvas.pack(side=Tkinter.TOP, fill=Tkinter.BOTH, expand=1)
        ########################################################################
        #                         Geracao do grafico                           #
        ########################################################################
        while flag_stop == False:
        #for i in range(0,2):
            #print 'flag graf', flag_stop
            delete()
            lista.extendleft(valor_plot)
            line.set_ydata(lista)
            canvas.draw()
开发者ID:IrvinRaneki,项目名称:CPqD-GSF,代码行数:33,代码来源:fapi_analyzer_cqi_indication.py

示例15: __init__

# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import draw [as 别名]
    def __init__(self, master, node_name='', figure_size=(5,4), dpi=100, is_polar=False):
        super().__init__(node_name=node_name)
        
        figure = Figure(figure_size, dpi)
        
        canvas = FigureCanvasTkAgg(figure, master=master)
        canvas.draw()
        
        self.__canvas = canvas
        toolbar = NavigationToolbar2Tk(canvas, master)
        toolbar.update()
        canvas.get_tk_widget().pack(side='top', fill='both', expand='yes')
        toolbar.pack()       
        
        # canvas.mpl_connect('button_press_event', lambda event:print(event)) # test mpl_connect
        
        with self.attribute_lock:
            # All the properties being set in this block will be locked automatically,
            # i.e. these properties cannot be replaced.
            set_attributes(self,
                figure      = figure,
                line_objects = [],       
                axes        = figure.add_subplot(111, polar=is_polar),
                is_polar     = is_polar
            )

        self.indicators = self.Indicators(data_figure=self)
        self.plot_function = None
        self.index  = None # Used by FigureList
        
        self.__major_grid    = is_polar
        self.__minor_grid    = False

        self.__indicatorsMeta   = []
开发者ID:xialulee,项目名称:WaveSyn,代码行数:36,代码来源:figurewindow.py


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