本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg.get_tk_widget方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasTkAgg.get_tk_widget方法的具体用法?Python FigureCanvasTkAgg.get_tk_widget怎么用?Python FigureCanvasTkAgg.get_tk_widget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
的用法示例。
在下文中一共展示了FigureCanvasTkAgg.get_tk_widget方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
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))
示例2: RSSIPlot
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [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)
示例3: update_saida
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def update_saida(self):
global canvas_latex,canvas_plots,latex_fig,plot_fig
try:
##Log de texto setando
self.saida_log_txt.delete(1.0, END)
self.saida_log_txt.insert(END,log_print())
canvas_plots.get_tk_widget().destroy()
canvas_latex.get_tk_widget().destroy()
latex_fig.clear()
plot_fig.clear()
latex_fig = print_latex()
plot_fig = show_plots()
canvas_plots = FigureCanvasTkAgg(plot_fig,self.frame_plot)
canvas_latex = FigureCanvasTkAgg(latex_fig,self.frame_latex)
canvas_latex.get_tk_widget().pack(side = TOP,fill = BOTH, expand = 1)
canvas_plots.get_tk_widget().pack(side = TOP,fill = BOTH, expand = 1)
except:
pass
示例4: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def __init__(self, x, y):
f = matplotlib.figure.Figure(figsize=(5, 4), dpi=100)
# f = matplotlib.figure.Figure(dpi=100)
ax = f.add_subplot(111)
canvas = ax.figure.canvas
line, = p.plot(x, y, animated=True, lw=2)
canvas = FigureCanvasTkAgg(f, master=root)
canvas.show()
canvas.get_tk_widget().grid()
toolbar = NavigationToolbar2TkAgg(canvas, root)
toolbar.update()
canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
p.subplots_adjust(left=-0.1, bottom=0.0)
manager = p.get_current_fig_manager()
manager.window.after(100, self.run)
self.canvas = canvas
self.ax = ax
self.line = line
self.x = x
self.y = y
示例5: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def __init__(self,parent,controller):
tk.Frame.__init__(self,parent)
label = tk.Label(self, text="Graph Page", font=LARGE_FONT)
label.pack(pady=10,padx=10)
button1 = ttk.Button(self,text="Back to Home",
command=lambda: controller.show_frame(StartPage))
button1.pack()
button2 = tk.Button(self,text="Page One",
command=lambda: controller.show_frame(PageOne))
button2.pack()
button3 = tk.Button(self,text="Page Two",
command=lambda: controller.show_frame(PageTwo))
button3.pack()
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.TOP,fill=tk.BOTH, expand = True)
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP,fill=tk.BOTH, expand = True)
示例6: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [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)
示例7: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
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()
示例8: graphic
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
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()
示例9: plotBERcurve
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def plotBERcurve(self):
row = 0
berCurveFrame = Tk.Frame(root, borderwidth=2, relief="raised", pady= 15, padx=10)
berCurveFrame.grid(row = row, column = 4, rowspan = 9, columnspan = 2, sticky = (Tk.N, Tk.W, Tk.E, Tk.S))
self.calculate = Tk.IntVar()
self.calculate.set(0)
calculate = Tk.Checkbutton(berCurveFrame, text=" Calculate", font=("Helvetica", 12), variable = self.calculate).grid(row = 2, column = 21, columnspan = 2, sticky=(Tk.W, Tk.E))
self.hold = Tk.IntVar()
self.hold.set(0)
hold = Tk.Checkbutton(berCurveFrame, text="Hold", font=("Helvetica", 12), variable = self.hold).grid(row = 3, column = 21, columnspan = 2, sticky=(Tk.W, Tk.E))
f = Figure(figsize=(4.5, 4.5), dpi=100)
a = f.add_subplot(111)
t = (1, 2, 3, 4)
s = (1, 2, 3, 4)
canvas = FigureCanvasTkAgg(f, berCurveFrame)
canvas.show()
canvas.get_tk_widget().grid(row= 1,column = 0,rowspan = 6, columnspan = 6, sticky = (Tk.N, Tk.W, Tk.E, Tk.S))
a.plot(t, s)
a.set_title('BER Curve')
a.set_xlabel('Eb/Nq')
a.set_ylabel('BER')
save = Tk.Button(berCurveFrame, text="Save", command = lambda: self.savePlotBER(f), bg = "cyan").grid(row=4, column = 21, columnspan = 2, padx = 15, sticky=(Tk.W, Tk.E))
clear = Tk.Button(berCurveFrame, text="Clear", command = lambda: self.clearPlot(f), bg = "cyan").grid(row=5, column = 21, columnspan = 2, padx = 15, sticky=(Tk.W, Tk.E))
示例10: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
class Plotter:
__fig = 1
__splot = 1
__canvas = 1
__toolbar = 1
def __init__(self,tk_root):
self.__fig = Figure(figsize=(5,5), dpi=100);
self.__splot = self.__fig.add_subplot(111)
self.__splot.grid()
self.__canvas = FigureCanvasTkAgg(self.__fig, master=tk_root)
self.__canvas.show()
self.__canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
self.__toolbar = NavigationToolbar2TkAgg(self.__canvas, tk_root)
self.__toolbar.update()
self.__canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
def add_to_plot(self,x,y,legend):
self.__splot.plot(x,y,'.-',label=legend)
self.__splot.legend()
self.__canvas.draw()
def plot_hist(self,data,bins):
self.__splot.hist(data,bins)
self.__canvas.draw()
def plot(self,x,y):
self.__splot.clear();
self.__splot.grid()
self.__splot.plot(x,y)
self.__canvas.draw()
示例11: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def __init__(self, parent, controller):
tk.Frame.__init__(self,parent)
label = tk.Label(self, text='Graph Page!', font=LARGE_FONT)
label.pack(pady=10,padx=10)
#add a button to navigate to a different page
button1 = ttk.Button(self, text='Back to Home',
command=lambda: controller.show_frame(StartPage))
#lambda creates a function on the fly so you can pass parameters
button1.pack()
f = Figure(figsize=(5,5), dpi=100)
a = f.add_subplot(111)
a.plot([1,2,3,4,5,6,7,8],[5,6,1,3,8,9,3,5])
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)
示例12: Application
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
class Application(Frame):
def __init__(self, master=None):
Frame.__init__(self, master)
self.grid()
self.master.title("Grid Manager")
for r in range(6):
self.master.rowconfigure(r, weight=1)
for c in range(5):
self.master.columnconfigure(c, weight=1)
Button(master, text="Button {0}".format(c)).grid(row=6,column=c,sticky=E+W)
Frame1 = Frame(master, bg="red")
Frame1.grid(row = 0, column = 0, rowspan = 3, columnspan = 2, sticky = W+E+N+S)
Frame2 = Frame(master, bg="blue")
Frame2.grid(row = 3, column = 0, rowspan = 3, columnspan = 2, sticky = W+E+N+S)
Frame3 = Frame(master, bg="green")
Frame3.grid(row = 0, column = 2, rowspan = 6, columnspan = 3, sticky = W+E+N+S)
self.fig = plt.figure(figsize=(10,10))
# ax=fig.add_axes([0.1,0.1,0.8,0.8],polar=True)
self.gs = GridSpec(3,1)
ax = self.fig.add_subplot(self.gs[0:2,:])
# self.im = ax.imshow(-np.random.random([128,128]), origin = 'upper', cmap=plt.cm.RdYlGn, interpolation = 'nearest', vmax=0, vmin=-400000)
#
self.canvas = FigureCanvasTkAgg(self.fig, master=Frame3)
# self.canvas.show()
# self.canvas.get_tk_widget().grid(side='top', fill='both', expand=1)
self.canvas.get_tk_widget().grid()
示例13: PlotGraph
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def PlotGraph(xValues, yValues, labelString):
## setup window
root = Tk()
root.wm_title("Graphed Projectile")
## setup frame
frame = Frame(root)
frame.pack()
label = Label(root, text=labelString, font=("Verdana", 12))
label.pack(pady=10, padx=10)
f = Figure(figsize=(5, 5), dpi=100)
a = f.add_subplot(111)
a.plot(xValues, yValues)
canvas = FigureCanvasTkAgg(f, root)
canvas.show()
canvas.get_tk_widget().pack(side=BOTTOM, fill=BOTH, expand=True)
toolbar = NavigationToolbar2TkAgg(canvas, root)
toolbar.update()
canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=True)
DataGrid(xValues, yValues)
root.mainloop()
示例14: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
label = tk.Label(self, text="Page three")
label.pack(padx=10, pady=10)
button = ttk.Button(self, text="Home",
command=lambda: controller.show_frame(StartPage))
button.pack()
# Data to plot
#f = Figure(figsize=(5, 5), dpi=100)
#a = f.add_subplot(111)
#a.plot([0,1,2,3,4,5,6,7,8], [0,2,7,3,5,1,7,8,2])
# Create a simple canvas
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=True)
# Navigation bar
toolbar = NavigationToolbar2TkAgg(canvas, self)
toolbar.update()
canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=True)
示例15: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import get_tk_widget [as 别名]
def __init__(self, parent, controller):
time.sleep(2)
tk.Frame.__init__(self, parent)
label = tk.Label(self, text='Before we begin, lets have a quick tutorial! \n\n'
'This simulation is designed to mimic that of the decline in real life, which is effecting us in ways '
'we can\'t understand today...\n ', font=LARGE_FONT)
label.pack(pady=10, padx=10)
f = Figure(figsize=(10,5), dpi=100)
a = f.add_subplot(111)
a.plot([1945, 1946, 1947, 1948, 1949, 1950, 1951, 1952, 1953, 1954, 1955, 1956, 1957, 1958, 1959, 1960,
1961, 1962, 1963, 1964, 1965, 1966, 1967, 1968, 1969, 1970, 1971, 1972, 1973, 1974, 1975, 1976,
1977, 1978, 1979, 1980, 1981, 1982, 1983, 1984, 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1992,
1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008,
2009, 2010],
[5500000, 5500000, 5430000, 5420000, 5425032, 5433200, 5503020, 5500030,
5435476, 5365343, 5322342, 5433454, 5762638, 5626379, 5533450, 5505032,
5325374, 5229382, 5332534, 5442435, 5632436, 5225356, 5354252, 5543344,
5544345, 5533453, 5433453, 5335344, 5345473, 5222223, 5199872, 5203002,
5102293, 5100330, 5093929, 5022332, 4999221, 4922322, 4822828, 4789800,
4733723, 4636364, 4444323, 4478779, 4422302, 4122321, 3999212, 4002293,
3888182, 3772373, 3642069, 3444333, 3220032, 3002230, 2883292, 2992283,
3322332, 3441422, 3322332, 2993828, 2777283, 2633543, 2339862, 2122039,
2100293, 2003993], 'g')
title = "Bee Population Decline Since 1945 (Bee Hives In Millions)"
a.set_title(title)
canvas = FigureCanvasTkAgg(f, self)
canvas.show()
canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)
button1 = tk.Button(self, text="Next", command=lambda:controller.show_frame(TutorialThree))
button1.pack()