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


Python FigureCanvasTkAgg.destroy方法代码示例

本文整理汇总了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()
开发者ID:kniezgoda,项目名称:picarro-crds-data-identifier,代码行数:18,代码来源:PicCRDS_DIA.1.0.py

示例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()
开发者ID:DrSree,项目名称:FishSurvey,代码行数:70,代码来源:gui.py


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