本文整理汇总了Python中matplotlib.backends.backend_tkagg.FigureCanvasTkAgg.destroy方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasTkAgg.destroy方法的具体用法?Python FigureCanvasTkAgg.destroy怎么用?Python FigureCanvasTkAgg.destroy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_tkagg.FigureCanvasTkAgg
的用法示例。
在下文中一共展示了FigureCanvasTkAgg.destroy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import destroy [as 别名]
class FigureWidget:
def __init__(self, parent, fig):
self.FigureRoot = parent
self.FigureRoot.title("Time Series Plot")
self.canvas = FigureCanvasTkAgg(fig, master=self.FigureRoot)
self.canvas = self.canvas.get_tk_widget()
self.canvas.pack(fill=BOTH,expand=YES)
def UpdatePlot(self, fig):
self.canvas.destroy()
self.canvas = FigureCanvasTkAgg(fig, master=self.FigureRoot)
self.canvas = self.canvas.get_tk_widget()
self.canvas.pack(fill=BOTH,expand=YES)
def destroy(self):
self.FigureRoot.destroy()
示例2: LakeSurvey
# 需要导入模块: from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg [as 别名]
# 或者: from matplotlib.backends.backend_tkagg.FigureCanvasTkAgg import destroy [as 别名]
class LakeSurvey(tk.Frame):
def __init__(self, parent, controller):
tk.Frame.__init__(self, parent)
self.titleframe = tk.Frame(self)
self.titleframe.pack()
self.comboframe = tk.Frame(self)
self.comboframe.pack()
self.canvasframe = tk.Frame(self)
self.canvasframe.pack()
self.label = tk.Label(self.titleframe, text='Fish survey for: '+DEFAULT_LAKE, font=LARGE_FONT)
self.label.pack(anchor='center', pady=10)
self.combovals = data['lakeName'].unique()
self.combovals.sort()
self.var = StringVar()
self.lakecombo = ttk.Combobox(self.comboframe, textvariable=self.var)
self.lakecombo.config(values=list(self.combovals))
self.lakecombo.bind('<<ComboboxSelected>>', lambda x: change_lake(self.var.get()))
self.lakecombo.pack(side=tk.LEFT, anchor='center', padx=10, pady=10)
self.button1 = ttk.Button(self.comboframe, text='Refresh',
command=lambda: self.refresh_button())
self.button1.pack(side=tk.LEFT, anchor='center')
self.button2 = ttk.Button(self.comboframe, text='Home',
command=lambda: controller.show_frame(StartPage))
self.button2.pack(side=tk.LEFT, anchor='center')
self.canvasframe.canvas = self.lake_plot()
self.canvas.pack(fill=tk.BOTH, expand=True, padx=100)
def lake_plot(self):
f = plt.figure()
a = f.add_subplot(111)
q1 = data[data['lakeName'] == DEFAULT_LAKE]
df = q1[['avgLen', 'avgWt', 'fishType']]
n = np.arange(len(df['fishType']))
a.clear()
a.bar(n, df['avgLen'], DEFAULT_WIDTH, label='Average Length')
a.bar(n+DEFAULT_WIDTH, df['avgWt'], DEFAULT_WIDTH, label='Average Weight', color='g')
a.set_xticks(n+DEFAULT_WIDTH)
a.set_xticklabels(list(df['fishType']),rotation=0, fontsize='small')
a.legend(bbox_to_anchor=(.8, 1.02), loc=8, ncol=2)
a.grid(False)
self.canvas = FigureCanvasTkAgg(f, self)
self.canvas = self.canvas.get_tk_widget()
return self.canvas
def refresh_button(self):
self.label.config(text='Fish survey for: '+DEFAULT_LAKE)
self.canvas.destroy()
self.canvasframe.canvas = self.lake_plot()
self.canvas.pack(fill=tk.BOTH, expand=True, padx=100)
def set_option(self):
global DEFAULT_LAKE
DEFAULT_LAKE = self.lakecombo.values.get()