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


Python backend_tkagg.FigureCanvasTkAgg类代码示例

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


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

示例1: __init__

    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        label = tk.Label(self, text="Red = train\nBlue = test", font=LARGE_FONT)
        label.pack(pady=10,padx=10,side=tk.RIGHT)

        '''
        check_button_train_var = tk.IntVar()
        check_button_train = tk.Checkbutton(self, text="Show Train Data", variable=check_button_train_var, \
                            onvalue=1, offvalue=0, height=5, \
                            width=20)
        check_button_train.pack(side = tk.RIGHT) # pady=5, padx=5,

        check_button_test_var = tk.IntVar()
        check_button_test = tk.Checkbutton(self, text="Show Test Data", variable=check_button_test_var, \
                                            onvalue=1, offvalue=0, height=5, \
                                            width=20)
        check_button_test.pack(side=tk.RIGHT)
        '''

        canvas = FigureCanvasTkAgg(f, self)
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        toolbar = NavigationToolbar2TkAgg(canvas, self)
        toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)

        draw_handler = DrawHandler(canvas)
开发者ID:xR86,项目名称:ml-stuff,代码行数:28,代码来源:matplot-reporter.py

示例2: Preview

class Preview(tk.Frame):
    #def __init__(self, parent, dim, dpi=36, label=None):
    def __init__(self, parent, dim, dpi=36, label=None, col=0, row=0):
        tk.Frame.__init__(self, parent)
        self.dim = dim
        self.bg = np.zeros((int(dim), int(dim)), float)
        ddim = dim/dpi
        self.figure = Figure(figsize=(ddim, ddim), dpi=dpi, frameon=False)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self)
        self.canvas.get_tk_widget().grid(column=0, row=0)#, sticky=(N, W, E, S))
        if label:
            tk.Label(self, text=label).grid(column=0, row=1)
        self._createAxes()
        
    def setWindowTitle(self,title):
        """ Set window title"""
        self.canvas.set_window_title(title)

    def _createAxes(self):
        """ Should be implemented in subclasses. """
        pass
    
    def _update(self):
        """ Should be implemented in subclasses. """
        pass
    
    def clear(self):
        self._update(self.bg)
        
    def updateData(self, Z):
        self.clear()
        self._update(Z)
开发者ID:I2PC,项目名称:scipion,代码行数:32,代码来源:matplotlib_image.py

示例3: build_graph

    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,代码行数:31,代码来源:gui.py

示例4: insert_frame

    def insert_frame(self, name, parent_frame_name, idx, frame_type=None, **kwargs):
        parent_frame = self.frames[parent_frame_name]
        frame = Frame(parent_frame)

        # add frame to list of frames
        self.frames[name] = frame

        # pre-fill the frame
        if frame_type is None:
            pass
        elif frame_type == 'plot':
            # generate canvas
            dim = kwargs['shape']
            f = Figure(figsize=dim, dpi=113  )
            a = f.add_subplot(111)
            canvas = FigureCanvasTkAgg(f, master=frame)
            
            # Commit the canvas to the gui
            canvas.get_tk_widget().pack()

            # save canvas data for later access
            self.mpl_data[name] = {}
            self.frame_data['plot'] = {'mpl_canvas':canvas}

        # commit the frame to workspace
        frame.grid(row=idx[0], column=idx[1])
开发者ID:ncsurobotics,项目名称:acoustics,代码行数:26,代码来源:gui_lib.py

示例5: __init__

class TriGUI:

	def __init__(self,root,canvas_width,canvas_height):
		self.root=root
		self.canvas_width = canvas_width
		self.canvas_height = canvas_height

		self.moduli_space = {'vertices':np.array([[0.,0.],[1.,0.],[0.5,np.sqrt(3.)/2.]]),'triangles':[0,1,2]}

		self.fig, self.ax = mpl.pyplot.subplots()
		self.ax.clear()
		self.ax.autoscale(enable=False)
		self.ax.axis('off')
		self.canvas = FigureCanvasTkAgg(self.fig,master=root)
		self.canvas.show()
		self.canvas.get_tk_widget().pack()

		X = self.moduli_space['vertices'][:,0]
		Y = self.moduli_space['vertices'][:,1]
		outline = tri.Triangulation(X,Y)
		self.ax.triplot(outline)

		#self.canvas.mpl_connect("button_press_event", self.setVertex)

	def quite(self):
		self.root.destroy()
开发者ID:necoleman,项目名称:fepy,代码行数:26,代码来源:triangle_survey_gui.py

示例6: attach_figure

 def attach_figure(figure, frame):
     canvas = FigureCanvasTkAgg(figure, master=frame)  # 内嵌散点图到UI
     canvas.show()
     canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
     toolbar = NavigationToolbar2TkAgg(canvas, frame)  # 内嵌散点图工具栏到UI
     toolbar.update()
     canvas.tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
开发者ID:vincent2610,项目名称:cancer-assessment,代码行数:7,代码来源:frame_test.py

示例7: __init__

class PlotClass:
    def __init__(self,master=[]):
        
        self.master=master
 
        #Erstellen des Fensters mit Rahmen und Canvas
        self.figure = Figure(figsize=(7,7), dpi=100)
        self.frame_c=Frame(relief = GROOVE,bd = 2)
        self.frame_c.pack(fill=BOTH, expand=1,)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self.frame_c)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(fill=BOTH, expand=1)

        #Erstellen der Toolbar unten
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame_c)
        self.toolbar.update()
        self.canvas._tkcanvas.pack( fill=BOTH, expand=1)

    def make_erg_plot(self,kegelst):
        self.plot1 = self.figure.add_subplot(111)
        self.plot1.set_title("Kegelstumpf Abwicklung")

        self.plot1.hold(True)

        for geo in kegelst.geo:
            geo.plot2plot(self.plot1)
开发者ID:arnew,项目名称:dxf2gcode,代码行数:26,代码来源:Kegelstump_Abwicklung_2dxf.py

示例8: drawFFTAndPath

def drawFFTAndPath(frame, x, y, freq, amp, titleCoP, titleFFT):
    f = Figure()

    gs = gridspec.GridSpec(1,2,width_ratios=[1,1],height_ratios=[1,1])

    a = f.add_subplot(gs[0])
    img = imread("Images/Wii.JPG")
    a.imshow(img, zorder=0, extent=[-216 - 26, 216 + 26, -114 - 26, 114 + 26])
    a.plot(x, y)
    a.set_title(titleCoP, fontsize=13)
    a.set_xlim([-216 - 30, 216 + 30])
    a.set_ylim([-114 - 30, 114 + 30])
    a.set_ylim([-114 - 30, 114 + 30])
    a.set_xlabel("CoPx (mm)", fontsize=12)
    a.set_ylabel("CoPy (mm)", fontsize=12)

    if amp[0] == 0:
        titleFFT = titleFFT + ' (0Hz filtered)'
    b = f.add_subplot(gs[1])
    b.plot(freq, amp)
    ttl = b.title
    ttl.set_position([.5, 1.05])
    b.set_title(titleFFT, fontsize=12)
    b.set_xlabel("Frequency (Hz)", fontsize=12)
    b.set_ylabel("Amplitude", fontsize=12)

    canvas = FigureCanvasTkAgg(f, frame)
    toolbar = NavigationToolbar2TkAgg(canvas, frame)
    canvas.show()
    canvas.get_tk_widget().pack(side=BOTTOM, fill=BOTH, expand=True)
    toolbar.update()
    canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=True)
开发者ID:DFNOsorio,项目名称:WiiBoard,代码行数:32,代码来源:ProcessDataGUI.py

示例9: __init__

class GraghFigure:
	def __init__(self, figFrame, figsizeX, figsizeY):

		self.fig = pylab.figure(dpi=fig_dpi, figsize=(figsizeX,figsizeY))
		self.canvas = FigureCanvasTkAgg(self.fig, master=figFrame)
		self.ax = self.fig.add_subplot(111)

		self.canvas.show()
		self.canvas.get_tk_widget().pack()
		self.ax.grid(True)
		self.line=[]
		self.line_num=-1

	def setAchse(self, xLabel, yLabel):
		self.xAchse=xAchse
		self.yAchse=yAchse
		self.ax.set_xlabel(xLabel)
		self.ax.set_ylabel(yLabel)

	def setAxis(self, x0,x1,y0,y1):
		self.ax.axis([x0,x1 ,y0,y1])

	def addplot(self, style):
		self.line.append(self.ax.plot(self.xAchse, self.yAchse, style, lw=3))
		#self.line = self.ax.plot(xAchse, yAchse, style)
		self.line_num = self.line_num + 1
		return self.line_num

	def plot(self, index, data_x, data_y):
		self.line[index][0].set_data(data_x, pylab.array(data_y))
开发者ID:mongmio,项目名称:ivyproject_thermal,代码行数:30,代码来源:monitor_gui.py

示例10: __init__

    def __init__(self, graph_frame, graph_config, graph_values):
        """
        graph_frame: tk frame to hold the graph_frame
        graph_config: configuration that was set from xml config parse
        graph_values: values that were generated as a result of graph config
        """ 
        self.logger = logging.getLogger('RT_Plot')
        self.logger.debug('__init__')


        # Create Line
        self.data_line = Line2D([],[])

        # Create plot
        self.plot_holder = Figure(figsize=(graph_values['x'], graph_values['y']), dpi=graph_values['dpi']) 
        self.rt_plot = self.plot_holder.add_subplot(111)
        self.rt_plot.add_line(self.data_line)
        
        # Set Title Configuration
        self.rt_plot.set_ylabel(graph_config['y_title']) 
        self.rt_plot.set_xlabel(graph_config['x_title']) 
        self.plot_holder.suptitle(graph_config['main_title'], fontsize=16)

        # Autoscale on unknown axis 
        self.rt_plot.set_autoscaley_on(True)
        self.rt_plot.set_autoscalex_on(True)
        # Set x limits?

        # Create canvas
        canvas = FigureCanvasTkAgg(self.plot_holder, master=graph_frame)
        canvas.show()
        # Attach canvas to graph frame
        canvas.get_tk_widget().grid(row=0, column=0)
开发者ID:david-kooi,项目名称:PythonWorks,代码行数:33,代码来源:RT_Plot.py

示例11: viewdata

def viewdata():
	graph = Toplevel()
	global SampleNos
	global Temperature
	graph.wm_title("Downloaded Data")
	graph.wm_iconbitmap(bitmap = "@/home/pi/meter.xbm")
	menubar = Menu(graph)
	filemenu = Menu(menubar, tearoff=0)
	filemenu.add_command(label="Open", command=openl)
	filemenu.add_command(label="Save", command=hello)
	filemenu.add_separator()
	filemenu.add_command(label="Exit", command=root.quit)
	menubar.add_cascade(label="File", menu=filemenu)
	graph.config(menu=menubar)
	f = Figure(figsize=(5, 4), dpi=100)
	a = f.add_subplot(111)
	t = arange(0.0, 3.0, 0.01)
	s = sin(2*pi*t)
	a.plot(SampleNos,Temperature, 'bo')
	canvas = FigureCanvasTkAgg(f, master=graph)
	canvas.show()
	canvas.get_tk_widget().pack()
	toolbar = NavigationToolbar2TkAgg(canvas, graph)
	toolbar.update()
	canvas._tkcanvas.pack()
开发者ID:hobbyelectronic,项目名称:datalogger,代码行数:25,代码来源:Datalogger.py

示例12: makeplottk

def makeplottk(targetdata):
	from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2TkAgg
	from matplotlib.backend_bases import key_press_handler
	from matplotlib.figure import Figure
	for i in range(0,len(targetdata)):
		targetdata[i]['data'][0]=[(j-2400000) for j in targetdata[i]['data'][0]]
	numplots=len(targetdata)
#this is where its different thatn makeplot, we need to set up the tk enviornment etc
	root=Tk()
	root.wm_title(targetdata[0]['name'])
	f=Figure(figsize=(10,8))
	for i in range(0,numplots):
		a=f.add_subplot(numplots,1,i+1)
		a.plot(targetdata[i]['data'][0],targetdata[i]['data'][1], 'ro')
		a.axes.invert_yaxis()
		a.legend(targetdata[i]['flt'])
	canvas=FigureCanvasTkAgg(f, master=root)
	canvas.show()
	canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
#now to add the cool widget bar
	toolbar = NavigationToolbar2TkAgg( canvas, root )
	toolbar.update()
	canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)
	mainloop()
	return
开发者ID:Astrophyzz,项目名称:INV,代码行数:25,代码来源:quickPlot.v2.py

示例13: Video

def Video():
    image1 = video.read(0)[1]
    axis1.imshow(image1)
    canvas1 = FigureCanvasTkAgg(videoFigure, master=window)
    canvas1.show()
    canvas1.get_tk_widget().pack(side=Tk.LEFT, fill=Tk.BOTH, expand=1)
    canvas1._tkcanvas.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=1)
开发者ID:SubinGeorge,项目名称:GitHub,代码行数:7,代码来源:testgui1.py

示例14: App

class App():
    def __init__(self):
        self.root = tk.Tk()
        self.root.wm_title("Embedding in TK")

        self.fig = plt.figure()
        self.ax = self.fig.add_subplot(111, projection='3d')
        self.ax.set_xlabel('X')
        self.ax.set_ylabel('Y')
        self.fig = function1(self.fig, self.ax)

        self.canvas = FigureCanvasTkAgg(self.fig, master=self.root)
        self.toolbar = NavigationToolbar2TkAgg( self.canvas, self.root )
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)

        self.label = tk.Label(text="")
        self.label.pack()
        self.update_clock()
        self.root.mainloop()

    def update_clock(self):
        self.fig = function1(self.fig,self.ax)
        self.canvas.show()
        self.canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        now = time.strftime("%H:%M:%S")
        self.label.configure(text=now)
        self.root.after(1000, self.update_clock)
开发者ID:EmanuelFontelles,项目名称:Bak-Tang-Wiesenfeld-Sandpile-Model,代码行数:28,代码来源:test1.py

示例15: graphic

def graphic(): 
  appears = varien*boltzmann*6e3
  f = plt.figure(figsize=(20,20))
  gs = plt.GridSpec(3, 2)
  mean1, o1, comp1 = analysis(snowblind, varien, "good", 0, gs)
  mean2, o2, comp2 = analysis(snowblind, appears, "month", 1, gs)
  burn = Tk()
  def another():
    burn.destroy()
  def andother():
    burn.destroy()
    sys.exit()
  burn.protocol('WM_DELETE_WINDOW', andother)
  burn.wm_title("Stadistic")
  canvas = FigureCanvasTkAgg(f, master = burn)
  toolbar = NavigationToolbar2TkAgg(canvas, burn)
  L1 = Label(burn, text="Your Mean is %s %s and your Mean Deviation is %s %s"%(str(mean1), str(comp1), str(o1), str(comp1)))
  L2 = Label(burn, text="Your Mean is %s %s and your Mean Deviation is %s %s"%(str(mean2), str(comp2), str(o2), str(comp2)))
  L3 = Label(burn, text="Your observation started in %s and finished in %s %s (UT) "%(timein, timeout, mirai[0]))
  B1 = Button(burn, text="Quit", bg="red", fg="white" ,command=andother)
  B2 = Button(burn, text="Another File", bg="blue", fg="white", command=another)
  L1.grid(columnspan=2)
  L2.grid(columnspan=2)
  L3.grid(columnspan=2)
  burn.grid_columnconfigure(1, weight=1)
  B1.grid(row=3, sticky=E)
  B2.grid(row=3, column=1, sticky=W)
  burn.grid_columnconfigure(0, weight=1)
  burn.grid_rowconfigure(4, weight=1)
  canvas.get_tk_widget().grid(row=4, columnspan=2, sticky=W)
  toolbar.grid(columnspan=2)
  burn.mainloop()
开发者ID:julian20250,项目名称:freezing-octo-happiness,代码行数:32,代码来源:graphic_stadistic.py


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