Python matplotlib.backends.backend_tkagg 模块,FigureCanvasTkAgg() 实例源码

我们从Python开源项目中,提取了以下50个代码示例,用于说明如何使用matplotlib.backends.backend_tkagg.FigureCanvasTkAgg()

项目:algo-trading-pipeline    作者:NeuralKnot    | 项目源码 | 文件源码
def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.configure(bg=BG_COLOR)

        self.trends = Figure(figsize=(5, 5), dpi=100)
        self.a = self.trends.add_subplot(111)

        canvas = FigureCanvasTkAgg(self.trends, self)
        canvas.show()
        canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)

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

        self.animation = FuncAnimation(self.trends, self.animate, 5000)
项目:BISIP    作者:clberube    | 项目源码 | 文件源码
def plot_window(self, fig, name=""):
        top_fig = tk.Toplevel()
        top_fig.lift()
        top_fig.title(name)
        top_fig.rowconfigure(1, weight=1)
        def _quit():
            top_fig.destroy()
        canvas = FigureCanvasTkAgg(fig, master=top_fig)
        canvas.show()
        canvas.get_tk_widget().grid(row=1, column=0, columnspan = 3, pady=(15,15), padx=(25,25), sticky=tk.N+tk.S+tk.E+tk.W)
        button = tk.Button(top_fig, height=1, width=20, text="Dismiss", bg='gray97', command=_quit, relief=tk.GROOVE)
        button.grid(row=2, column=0, columnspan=1, sticky=tk.W, pady=(10,10), padx=(20,20))
        toolbar_frame = tk.Frame(top_fig)
        toolbar_frame.grid(row=0,column=0,columnspan=2, sticky=tk.W+tk.E)
        NavigationToolbar2TkAgg( canvas, toolbar_frame )
        top_fig.resizable(width=tk.FALSE, height=tk.FALSE)
项目:BISIP    作者:clberube    | 项目源码 | 文件源码
def plot_window(self, fig, name=""):
        top_fig = tk.Toplevel()
        top_fig.lift()
        top_fig.title(name)
        top_fig.rowconfigure(1, weight=1)
        def _quit():
            top_fig.destroy()
        canvas = FigureCanvasTkAgg(fig, master=top_fig)
        canvas.show()
        canvas.get_tk_widget().grid(row=1, column=0, columnspan = 3, pady=(15,15), padx=(25,25), sticky=tk.N+tk.S+tk.E+tk.W)
        button = tk.Button(top_fig, height=1, width=20, text="Dismiss", bg='gray97', command=_quit, relief=tk.GROOVE)
        button.grid(row=2, column=0, columnspan=1, sticky=tk.W, pady=(10,10), padx=(20,20))
        toolbar_frame = tk.Frame(top_fig)
        toolbar_frame.grid(row=0,column=0,columnspan=2, sticky=tk.W+tk.E)
        NavigationToolbar2TkAgg( canvas, toolbar_frame )
        top_fig.resizable(width=tk.FALSE, height=tk.FALSE)
项目:autopen    作者:autopen    | 项目源码 | 文件源码
def plot1(self, x, y, ticks, strlab, ID):
        self.f = Figure(figsize=(3,4), dpi=100)
        self.ax1 = self.f.add_subplot(111)
        self.canvas = FigureCanvasTkAgg(self.f, master=root)
        self.canvas.show()
        self.canvas.get_tk_widget().grid(row = 0, column = 0, rowspan = 3, columnspan = 1, sticky = W+E+N+S) 
        self.ax1.set_xticklabels(ticks)

        for tick in self.ax1.xaxis.get_major_ticks():
            tick.label.set_fontsize(6) 
            # specify integer or one of preset strings, e.g.
            #tick.label.set_fontsize('x-small') 
            tick.label.set_rotation(30)

        if(strlab == "INT"):
            self.ax1.set_title('Integral Graph: %s' % ID) 
        if(strlab == "FRQ"):
            self.ax1.set_title('Frequency Graph: %s' % ID) 

        self.ax1.plot(x,y)
项目:autopen    作者:autopen    | 项目源码 | 文件源码
def plot2(self, x, y, ticks, strlab, ID):
        self.f1 = Figure(figsize=(3,4), dpi=100)
        self.ax2 = self.f1.add_subplot(111)
        self.canvas4 = FigureCanvasTkAgg(self.f1, master=root)
        self.canvas4.show()
        self.canvas4.get_tk_widget().grid(row = 3, column = 0, rowspan = 3, columnspan = 1, sticky = W+E+N+S)
        self.ax2.set_xticklabels(ticks)

        for tick in self.ax2.xaxis.get_major_ticks():
            tick.label.set_fontsize(6) 
            # specify integer or one of preset strings, e.g.
            #tick.label.set_fontsize('x-small') 
            tick.label.set_rotation(30)

        if(strlab == "INT"):
            self.ax2.set_title('Integral Graph: %s' % ID) 
        if(strlab == "FRQ"):
            self.ax2.set_title('Frequency Graph: %s' % ID) 

        self.ax2.plot(x,y)

    # Search tree by ARB ID
项目:pyktrader2    作者:harveywwu    | 项目源码 | 文件源码
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()

        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)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
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)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
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)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
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)
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def initialize_display(self):
        self.openButton = tk.Button(self, text = "Open File", command = self.get_filepath)
        self.openButton.grid(row = 0, column = 0)
        # This is just here to easily close the app during testing
        self.quitButton = tk.Button(self, text = "Quit", command = self.quit)
        self.quitButton.grid(row = 1, column = 0)

        # testing alternative plotting solution

        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(t, s)
        canvas = FigureCanvasTkAgg(f, master=drawing_panel)
        canvas.show()
        # canvas.get_tk_widget().grid(row = 10, column = 10)
        # canvas._tkcanvas.grid(row = 10, column = 10)
        canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        # toolbar = NavigationToolbar2TkAgg(canvas, root)
        # toolbar.update()
        canvas._tkcanvas.pack(side=tk.TOP, fill=tk.BOTH, expand=1)
项目:EasyMKL    作者:jmikko    | 项目源码 | 文件源码
def __init__(self, root, controller):
        f = Figure()
        nticks = 10
        ax = f.add_subplot(111, aspect='1')
        ax.set_xticks([x*(x_max-x_min)/nticks+x_min for x in range(nticks+1)])
        ax.set_yticks([y*(y_max-y_min)/nticks+y_min for y in range(1,nticks+1)])
        ax.set_xlim((x_min, x_max))
        ax.set_ylim((y_min, y_max))
        canvas = FigureCanvasTkAgg(f, master=root)
        canvas.show()
        canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        canvas.mpl_connect('button_press_event', self.onclick)
        toolbar = NavigationToolbar2TkAgg(canvas, root)
        toolbar.update()
        self.controllbar = ControllBar(root, controller)
        self.f = f
        self.ax = ax
        self.canvas = canvas
        self.controller = controller
        self.contours = []
        self.c_labels = None
        self.plot_kernels()
项目:PaleoView    作者:GlobalEcologyLab    | 项目源码 | 文件源码
def updateRegionMap(self, user_defined_update=False, time_dependent_update=False, time_dependent_year=None) :

        # Re-plot the region map
        self.view_edit_region_plot_axes.clear()
        self.createRegionFigure(update=True, user_defined_update=user_defined_update, time_dependent_update=time_dependent_update, time_dependent_year=time_dependent_year)
        if user_defined_update or time_dependent_update:
            self.view_edit_region_canvas.draw()
        else :
            self.view_edit_region_window.title(self.view_edit_region_button_text.get())
            self.view_edit_region_canvas.get_tk_widget().grid_remove()
            self.view_edit_region_canvas = FigureCanvasTkAgg(self.view_edit_region_figure, master=self.view_edit_region_frame)
            self.view_edit_region_canvas.show()
            self.view_edit_region_canvas.get_tk_widget().grid(row=0, column=0)

        if self.current_region == 'user-defined' :
            if (self.region_mask > 0).any() :
                self.user_defined_region_ok_button.configure(state=tk.NORMAL)
            else :
                self.user_defined_region_ok_button.configure(state=tk.DISABLED)
        elif self.region_is_time_dependent[self.current_region] :
            self.updateTimeDependentPreviousNext(time_dependent_year)

    # Step 3 Method: Update Region Mask
项目:shopbot_voxel_builder    作者:codedstructureslab    | 项目源码 | 文件源码
def setup_GUI(fig):
    # working with GUI --------------------------------------------
    print '\ninitializing...'

    GUI = tk.Tk()
    GUI.title('CSL - Autovox')
    GUI.minsize(150,150)
    GUI.geometry('1280x400+0+0')

    f0 = tk.Frame(GUI)                            # defining frame
    f0.pack(fill='both',expand=True)

    f0_area = tk.Canvas(f0, width=10,height=10)   # defining canvas area within frame
    f0_area.pack(side=tk.TOP)

    graph = FigureCanvasTkAgg(fig)
    graph.show()
    graph.pack()
    # but1 = tk.Button(f0, text='Show Voxel Build', height=1, width=15, command= lambda: show_vox_build())
    # but1.pack(side=tk.RIGHT)
    # f0_area.create_window(10,10, window=but1)

    GUI.mainloop()
    # -------------------------------------------------------------
项目:PyEveLiveDPS    作者:ArtificialQualia    | 项目源码 | 文件源码
def makeGraph(self):
        self.graphFigure = Figure(figsize=(1,0.1), dpi=50, facecolor="black")

        self.subplot = self.graphFigure.add_subplot(1,1,1, facecolor=(0.3, 0.3, 0.3))
        self.subplot.tick_params(axis="y", colors="grey", labelbottom="off", bottom="off")
        self.subplot.tick_params(axis="x", colors="grey", labelbottom="off", bottom="off")

        self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
        self.graphFigure.subplots_adjust(left=0, bottom=0, right=1, top=1, wspace=0, hspace=0)

        self.graphCanvas = FigureCanvasTkAgg(self.graphFigure, self)
        self.graphCanvas.get_tk_widget().configure(bg="black")
        self.graphCanvas.get_tk_widget().grid(row="2", column="2", columnspan="3", sticky="news")

        yValues = self.mainWindow.characterDetector.playbackLogReader.logEntryFrequency
        self.highestValue = 0
        for value in yValues:
            if value > self.highestValue: self.highestValue = value
        self.subplot.plot(yValues, "dodgerblue")
        self.timeLine, = self.subplot.plot([0, 0], [0, self.highestValue], "white")
        #self.graphFigure.axes[0].set_xlim(0, len(yValues))
        self.subplot.margins(0.005,0.01)

        self.graphCanvas.show()
        self.mainWindow.makeDraggable(self.graphCanvas.get_tk_widget())
项目:PyEveLiveDPS    作者:ArtificialQualia    | 项目源码 | 文件源码
def __init__(self, parent, settings, labelHandler, **kwargs):
        tk.Frame.__init__(self, parent, **kwargs)

        self.parent = parent
        self.labelHandler = labelHandler
        self.settings = settings

        self.degree = 5
        self.windowWidth = self.settings.getWindowWidth()

        self.graphFigure = Figure(figsize=(4,2), dpi=100, facecolor="black")

        self.subplot = self.graphFigure.add_subplot(1,1,1, facecolor=(0.3, 0.3, 0.3))
        self.subplot.tick_params(axis="y", colors="grey", direction="in")
        self.subplot.tick_params(axis="x", colors="grey", labelbottom="off", bottom="off")

        self.graphFigure.axes[0].get_xaxis().set_ticklabels([])
        self.graphFigure.subplots_adjust(left=(30/self.windowWidth), bottom=(15/self.windowWidth), 
                                         right=1, top=(1-15/self.windowWidth), wspace=0, hspace=0)

        self.canvas = FigureCanvasTkAgg(self.graphFigure, self)
        self.canvas.get_tk_widget().configure(bg="black")
        self.canvas.get_tk_widget().pack(side=tk.BOTTOM, fill=tk.BOTH, expand=True)

        self.canvas.show()
项目:Parallel-SGD    作者:angadgill    | 项目源码 | 文件源码
def __init__(self, root, controller):
        f = Figure()
        ax = f.add_subplot(111)
        ax.set_xticks([])
        ax.set_yticks([])
        ax.set_xlim((x_min, x_max))
        ax.set_ylim((y_min, y_max))
        canvas = FigureCanvasTkAgg(f, master=root)
        canvas.show()
        canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        canvas.mpl_connect('button_press_event', self.onclick)
        toolbar = NavigationToolbar2TkAgg(canvas, root)
        toolbar.update()
        self.controllbar = ControllBar(root, controller)
        self.f = f
        self.ax = ax
        self.canvas = canvas
        self.controller = controller
        self.contours = []
        self.c_labels = None
        self.plot_kernels()
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def __loadMatplotlib(self):
        global FigureCanvasTkAgg, Figure

        if FigureCanvasTkAgg is None:
            try:
                from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
                from matplotlib.figure import Figure
            except:
                FigureCanvasTkAgg = Figure = False
项目:SceneDensity    作者:ImOmid    | 项目源码 | 文件源码
def addPlot(
            self,
            title,
            t, s,
            row=None,
            column=0,
            colspan=0,
            rowspan=0):
        self.__verifyItem(self.n_plots, title, True)

        self.__loadMatplotlib()
        if FigureCanvasTkAgg is False:
            raise Exception("Unable to load MatPlotLib - plots not available")
        else:
            fig = Figure()

            axes = fig.add_subplot(111)
            axes.plot(t,s)

            canvas = FigureCanvasTkAgg(fig, self.__getContainer())
            canvas.fig = fig
            canvas.axes = axes
            canvas.show()
    #        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
            canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

            self.__positionWidget(canvas.get_tk_widget(), row, column, colspan, rowspan)
            self.n_plots[title] = canvas
            return axes
项目:python-QuickUI    作者:ac1235    | 项目源码 | 文件源码
def init_ui(self, root):
    self.figure = Figure(figsize=(5,5), dpi=100)
    self.subplot = self.figure.add_subplot(111)
    self.canvas = FigureCanvasTkAgg(self.figure, root)
    self.canvas.show()
    self.canvas.get_tk_widget().pack(fill=tk.BOTH, expand=1)
    toolbar = NavigationToolbar2TkAgg(self.canvas, root)
    toolbar.update()
项目:mav_rtk_gps    作者:ethz-asl    | 项目源码 | 文件源码
def __init__(self, parent_window):
        # Topic Names.
        self.topic_names = self.get_topic_names()

        self.main_label = Label(parent_window, text="RTK Fix Plot", font="Times 14 bold")
        self.main_label.grid(row=0, columnspan=2)

        # Plot for RTK fix.
        self.first_receiver_state_received = False
        self.first_time_receiver_state = 0

        self.figure = Figure(figsize=(figureSizeWidth, figureSizeHeight), dpi=75)

        self.axes_rtk_fix = self.figure.add_subplot(111)
        self.axes_rtk_fix.set_xlabel('Time [s]')
        self.axes_rtk_fix.set_ylabel('RTK Fix')
        self.axes_rtk_fix.grid()
        self.figure.tight_layout()
        self.axes_rtk_fix.set_yticks([0.0, 1.0])

        self.canvas = FigureCanvasTkAgg(self.figure, master=parent_window)
        self.canvas.show()
        self.canvas.get_tk_widget().grid(rowspan=4, columnspan=2)

        # Position data.
        self.odometry_msg_count = 0
        self.time_rtk_fix = deque([], maxlen=maxLengthDequeArray)
        self.rtk_fix = deque([], maxlen=maxLengthDequeArray)
        self.line_rtk_fix = []

        # Subscribe to topics.
        rospy.Subscriber(self.topic_names['piksi_receiver_state'], ReceiverState,
                         self.receiver_state_callback)
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def __loadMatplotlib(self):
        global FigureCanvasTkAgg, Figure

        if FigureCanvasTkAgg is None:
            try:
                from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
                from matplotlib.figure import Figure
            except:
                FigureCanvasTkAgg = Figure = False
项目:Cryptokey_Generator    作者:8BitCookie    | 项目源码 | 文件源码
def addPlot(
            self,
            title,
            t, s,
            row=None,
            column=0,
            colspan=0,
            rowspan=0):
        self.__verifyItem(self.n_plots, title, True)

        self.__loadMatplotlib()
        if FigureCanvasTkAgg is False:
            raise Exception("Unable to load MatPlotLib - plots not available")
        else:
            fig = Figure()

            axes = fig.add_subplot(111)
            axes.plot(t,s)

            canvas = FigureCanvasTkAgg(fig, self.__getContainer())
            canvas.fig = fig
            canvas.axes = axes
            canvas.show()
    #        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
            canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

            self.__positionWidget(canvas.get_tk_widget(), row, column, colspan, rowspan)
            self.n_plots[title] = canvas
            return axes
项目:IM_Climate    作者:IMDProjects    | 项目源码 | 文件源码
def drawGraph(self, *args):
        '''
        Method to draw the matplotlib graph
        '''

        self.graphFrame = Tk.Frame(self.root)
        f = Figure(figsize=(7,5), dpi=100)
        subplot = f.add_subplot(111)
        if self.plotType == 'line':
            #a.plot(self.xAxis, self.yData)
            subplot.plot(self.falseX, self.yData)
        elif self.plotType == 'bar':
            subplot.bar(self.xAxis, self.yData)
        subplot.set_title(self.Title.get())
        subplot.set_xlabel(self.xLabel.get())
        subplot.set_ylabel(self.yLabel.get())
        subplot.set_ylim(self.yMin.get(), self.yMax.get())
        subplot.set_xlim(self.xMin.get(), self.xMax.get())
        #a.set_xticklabels( self.xTicLabel.get(),  rotation = 45)
        #a.set_xticklabels(map(str, self.xAxis), rotation = 45)
        subplot.xticks(self.falseX, map(str, self.xAxis), rotation='vertical')

        # a tk.DrawingArea
        self.canvas = FigureCanvasTkAgg(f, master = self.graphFrame)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self.graphFrame.grid(row=1, rowspan=10)
项目:piwall-cvtools    作者:infinnovation    | 项目源码 | 文件源码
def __init__(self, master):
        self.frame = Tk.Frame(master)
        self.fig = Figure( figsize=(7.5, 4), dpi=80 )
        self.ax0 = self.fig.add_axes( (0.05, .05, .90, .90), axisbg=(.75,.75,.75), frameon=False)
        self.frame.pack(side=Tk.LEFT, fill=Tk.BOTH, expand=1)
        self.sidepanel=SidePanel(master)
        self.canvas = FigureCanvasTkAgg(self.fig, master=self.frame)
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)
        self.canvas.show()
项目:cadee    作者:kamerlinlab    | 项目源码 | 文件源码
def __init__(self, parent, plotdata, plotdata_files):
        self.parent = parent
        self.plots = plotdata   # example:  { "dgde" : { 0 : QPlotData_instance (from file 1), 1 : QPlotData_instance (from file 2) }, ... }, where 0,1,... are indices of the filenames in plotdata_files
        self.plotdata_files = plotdata_files    #  [ "/home/.../pro/qa.PlotData.pickle", "/home/.../wat/qa.PlotData.pickle" ]
        self.nrows = 1
        self.ncols = 1
        self.blocked_draw = False
        self.subplot_lines = {}
        self.COLORS_ACTIVE = ("#555555","#F75D59","#1589FF", "black", "red", "blue")
        self.COLORS_INACTIVE = ("#aaaaaa","#F7bDb9","#a5a9FF", "#999999", "#FFaaaa", "#aaaaFF")


        self.lb1_entries = ODict()
        for plot_key, plot in self.plots.iteritems():
            self.lb1_entries[ plot.values()[0].title ] = plot_key

        self.lb1 = Tk.Listbox(self.parent, selectmode=Tk.EXTENDED, exportselection=0)

        for plot_title in self.lb1_entries.keys():
            self.lb1.insert(Tk.END, plot_title)

        self.lb1.pack(fill=Tk.Y, side=Tk.LEFT)
        self.lb2 = Tk.Listbox(self.parent, selectmode=Tk.EXTENDED, exportselection=0)
        self.lb2.pack(fill=Tk.Y, side=Tk.LEFT)

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


        self.canvas = FigureCanvasTkAgg(self.figure, master=self.parent)
        self.canvas.get_tk_widget().pack()
        self.canvas._tkcanvas.pack(fill=Tk.BOTH, expand=1)

        self.toolbar = NavigationToolbar2TkAgg( self.canvas, self.parent )
        self.toolbar.update()
        self.canvas._tkcanvas.pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        self.lb1.bind("<<ListboxSelect>>", self.on_select_lb1)
        self.lb2.bind("<<ListboxSelect>>", self.on_select_lb2)
        self.parent.bind("<Configure>", self.on_resize)
项目:StochOPy    作者:keurfonluu    | 项目源码 | 文件源码
def frame2(self):
        from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg

        self.frame2 = ttk.Frame(self.master, borderwidth = 2, relief = "groove")
        self.frame2.place(bordermode = "outside", relwidth = 0.99, relheight = 0.72, relx = 0, rely = 0.22, x = 5, y = 5, anchor = "nw")
        self.frame2.canvas = ttk.Frame(self.frame2, borderwidth = 0)
        self.frame2.canvas.place(relwidth = 1, relheight = 1, relx = 0, anchor = "nw")
        self.fig = Figure(figsize = (13, 6), facecolor = "white")
        self.canvas = FigureCanvasTkAgg(self.fig, master = self.frame2.canvas)
        self.fig.canvas.mpl_connect("button_press_event", self._onClick)
        self.canvas.get_tk_widget().pack()
项目:copycat    作者:LSaldyt    | 项目源码 | 文件源码
def __init__(self, parent, status, title):
        ttk.Frame.__init__(self, parent)
        self.status = status

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

        self.animation = animation.FuncAnimation(status.figure, lambda i : status.update_plots(i), interval=1000)
项目:antlang4python    作者:AntLang-Software    | 项目源码 | 文件源码
def init_ui(self, root):
    self.figure = Figure(figsize=(5,5), dpi=100)
    self.subplot = self.figure.add_subplot(111)
    self.canvas = FigureCanvasTkAgg(self.figure, root)
    self.canvas.show()
    self.canvas.get_tk_widget().pack(fill=tk.BOTH, expand=1)
    toolbar = NavigationToolbar2TkAgg(self.canvas, root)
    toolbar.update()
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
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)
项目:dxf2gcode    作者:cnc-club    | 项目源码 | 文件源码
def __init__(self, master=None, iter=None):

        self.master = master
        self.iter = iter

        self.frame_o = Frame(height=50, relief=GROOVE, bd=2)
        self.frame_o.pack(fill=BOTH, expand=1)

        self.but_update_plot = Button(master=self.frame_o,
                                      text='Start Animation',
                                      command=self.iter.start_animation)
        self.but_update_plot.pack(fill=BOTH, expand=1)

        self.figure = Figure(figsize=(6, 7), dpi=100)

        # a tk.DrawingArea
        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)

        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.frame_c)
        self.toolbar.update()
        self.canvas._tkcanvas.pack( fill=BOTH, expand=1)
        self.ini_plot()
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def show_histogram(self):
        """Generate histogram
            event - STRING - sent by self.x_column_selector when a column is selected"""


        column_name = self.x_column_selected.get()
        # histogram generated here - reference the canvas() method for the variable names to generate the plot
        print("Histogram with " + column_name + " x column to be generated")
        self.f = Figure(figsize = (6,4), dpi = 100)
        self.a = self.f.add_subplot(111)
        self.a = self.histogram_object.generate(column_name, self.a, color = self.plot_color)
        self.canvas = FigureCanvasTkAgg(self.f, master=self)
        self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, sticky="nesw")
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def show_scatter_plot(self):
        """Generate scatter plot
            event - STRING - sent by self.x_column_selector or self.y_column_selector when a column is selected"""


        x_column_name = self.x_column_selected.get()
        y_column_name = self.y_column_selected.get()
        # scatter plot generated here - reference the canvas() method for the variable names to generate the plot
        if x_column_name == "" or y_column_name == "":
            print("Both columns are not filled wont generate scatter plot")
        elif x_column_name == y_column_name:
            # print("Both columns are the same cannot plot")
            self.same_columns_warning_label.grid()
            self.same_columns_warning_label_isVisible = True
        else:
             # make sure warning label isnt there
            if self.same_columns_warning_label_isVisible == True:
                self.same_columns_warning_label.grid_remove()
                self.same_columns_warning_label_isVisible = False


            self.f = Figure(figsize = (6,4), dpi = 100)
            self.a = self.f.add_subplot(111)
            self.a = self.scatter_object.generate(x_column_name, y_column_name, self.a, color = self.plot_color)
            self.canvas = FigureCanvasTkAgg(self.f, master=self)
            self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, sticky="nesw")
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def show_regression_scatter_plot(self):
        """Generate scatter plot with a regression line
            event - STRING - sent by self.x_column_selector or self.y_column_selector when a column is selected"""


        x_column_name = self.x_column_selected.get()
        y_column_name = self.y_column_selected.get()
        # scatter plot generated here - reference the canvas() method for the variable names to generate the plot
        if x_column_name == "" or y_column_name == "":
            print("Both columns are not filled wont generate scatter plot")
        elif x_column_name == y_column_name:
            # print("Both columns are the same cannot plot")
            self.same_columns_warning_label.grid()
            self.same_columns_warning_label_isVisible = True
        else:

            # make sure warning label isnt there
            if self.same_columns_warning_label_isVisible == True:
                self.same_columns_warning_label.grid_remove()
                self.same_columns_warning_label_isVisible = False


            self.f = Figure(figsize = (6,4), dpi = 100)
            self.a = self.f.add_subplot(111)
            self.a = self.scatter_object.lin_generate(x_column_name, y_column_name, self.a, color = self.plot_color)
            self.canvas = FigureCanvasTkAgg(self.f, master=self)
            self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, sticky="nesw")
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def create_canvas(self):
        """Creates a canvas object to draw matplotlib visualizations on
            self.f - Figure - contains the figure object for all of the subplots
            self.a - Plot - the plot in question.
            self.canvas - FigureCanvasTkAgg - tkinter widget that holds figure"""


        self.f = Figure(figsize = (6,4), dpi = 100)
        self.a = self.f.add_subplot(111)

        self.canvas = FigureCanvasTkAgg(self.f, master=self)
        self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, columnspan = 6, sticky="nesw")

        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.master) #do we want to keep this? it allows the user to save the plot so probs useful
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def show_scatter_plot(self):
        """Generate scatter plot
            event - STRING - sent by self.x_column_selector or self.y_column_selector when a column is selected"""


        x_column_name = self.x_column_selected.get()
        y_column_name = self.y_column_selected.get()
        # scatter plot generated here - reference the canvas() method for the variable names to generate the plot
        if x_column_name == "" or y_column_name == "":
            print("Both columns are not filled wont generate scatter plot")
        elif x_column_name == y_column_name:
            # print("Both columns are the same cannot plot")
            self.same_columns_warning_label.grid()
            self.same_columns_warning_label_isVisible = True
        else:
             # make sure warning label isnt there
            if self.same_columns_warning_label_isVisible == True:
                self.same_columns_warning_label.grid_remove()
                self.same_columns_warning_label_isVisible = False


            self.f = Figure(figsize = (6,4), dpi = 100)
            self.a = self.f.add_subplot(111)
            self.a = self.scatter_object.generate(x_column_name, y_column_name, self.a, color = self.plot_color)
            self.canvas = FigureCanvasTkAgg(self.f, master=self)
            self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, sticky="nesw")
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def show_regression_scatter_plot(self):
        """Generate scatter plot with a regression line
            event - STRING - sent by self.x_column_selector or self.y_column_selector when a column is selected"""


        x_column_name = self.x_column_selected.get()
        y_column_name = self.y_column_selected.get()
        # scatter plot generated here - reference the canvas() method for the variable names to generate the plot
        if x_column_name == "" or y_column_name == "":
            print("Both columns are not filled wont generate scatter plot")
        elif x_column_name == y_column_name:
            # print("Both columns are the same cannot plot")
            self.same_columns_warning_label.grid()
            self.same_columns_warning_label_isVisible = True
        else:

            # make sure warning label isnt there
            if self.same_columns_warning_label_isVisible == True:
                self.same_columns_warning_label.grid_remove()
                self.same_columns_warning_label_isVisible = False


            self.f = Figure(figsize = (6,4), dpi = 100)
            self.a = self.f.add_subplot(111)
            self.a = self.scatter_object.lin_generate(x_column_name, y_column_name, self.a, color = self.plot_color)
            self.canvas = FigureCanvasTkAgg(self.f, master=self)
            self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, sticky="nesw")
项目:Dame    作者:jdhouti    | 项目源码 | 文件源码
def create_canvas(self):
        """Creates a canvas object to draw matplotlib visualizations on
            self.f - Figure - contains the figure object for all of the subplots
            self.a - Plot - the plot in question.
            self.canvas - FigureCanvasTkAgg - tkinter widget that holds figure"""


        self.f = Figure(figsize = (6,4), dpi = 100)
        self.a = self.f.add_subplot(111)

        self.canvas = FigureCanvasTkAgg(self.f, master=self)
        self.canvas.get_tk_widget().grid(column=3, row=1, rowspan=5, columnspan = 6, sticky="nesw")

        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.master) #do we want to keep this? it allows the user to save the plot so probs useful
项目:brillouin-zones    作者:sajadabasi    | 项目源码 | 文件源码
def __init__(self, a1, a2, size):
        self.a1 = a1;
        self.a2 = a2;
        self.size = size;
        self.x = np.arange(-1 * self.size, self.size, 0.01);
        self.y = np.arange(-1 * self.size, self.size, 0.01);

        self.pointsX = [];
        self.pointsY = [];
        self.non = 0;
        self.distances = [];

        root = Tk.Tk()
        root.wm_title("Embedding in TK")
        self.f = Figure()
        self.plt = self.f.add_subplot(1, 1, 1)

        self.main();
        self.update();
        # a tk.DrawingArea
        self.canvas = FigureCanvasTkAgg(self.f, master=root)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        nextBtn = Tk.Button(master=root, text='Next', command=self.next)
        backBtn = Tk.Button(master=root, text='Back', command=self.back)
        quitBtn = Tk.Button(master=root, text='Quit', command=sys.exit)
        nextBtn.pack(side=Tk.RIGHT)
        backBtn.pack(side=Tk.RIGHT)
        quitBtn.pack(side=Tk.LEFT)

        Tk.mainloop()
项目:vbcg    作者:nspi    | 项目源码 | 文件源码
def __create_gui(self):

        # Add subplots
        self.figure = Mat_figure(figsize=(5, 3), dpi=100)
        self.subplotTop = self.figure.add_subplot(211)
        self.subplotBottom = self.figure.add_subplot(212)

        # Add labels
        self.subplotTop.set_xlabel('Frames')
        self.subplotBottom.set_xlabel('Hz')
        # Change font size
        matplotlib.rcParams.update({'font.size': 10})

        # Create canvas
        self.canvas = FigureCanvasTkAgg(self.figure, master=self.root)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=Tk.TOP, fill=Tk.BOTH, expand=1)

        # We store the data that is interchanged from GuiSignalProcessor to GuiSignalPlotter in a queue
        self.dataQueue = LifoQueue()

        # Create thread that displays signal
        self.signalPlotThread = GuiSignalPlotter(self.root, self.cameraInstance, self.figure, self.canvas,
                                                 self.subplotTop, self.subplotBottom, self.statusbar,
                                                 self.video_display, self.dataQueue)
        # Create thread that processes signal
        self.signalProcessorThread = GuiSignalProcessor(self.root, self.cameraInstance, self.figure, self.canvas,
                                                        self.subplotTop, self.subplotBottom, self.statusbar,
                                                        self.video_display, self.dataQueue)

        # Start both threads
        self.signalPlotThread.start()
        self.signalProcessorThread.start()
项目:shopbot_voxel_builder    作者:codedstructureslab    | 项目源码 | 文件源码
def setup_GUI(fig):
    # working with GUI --------------------------------------------
    print '\ninitializing...'
    # print 'SHELL, "echo ' + '"Start Time:' + ' >> voxBuildTiming.log"'
    # print 'SHELL, "echo %date% %time% >> voxBuildTiming.log"'  # windows shell
    # print 'SHELL, "date >> voxBuildTiming.log"'  # linux shell


    GUI = tk.Tk()
    GUI.title('CSL - Autovox')
    GUI.minsize(150,150)
    GUI.geometry('1280x400+0+0')

    f0 = tk.Frame(GUI)                            # defining frame
    f0.pack(fill='both',expand=True)

    f0_area = tk.Canvas(f0, width=10,height=10)   # defining canvas area within frame
    f0_area.pack(side=tk.TOP)

    graph = FigureCanvasTkAgg(fig)
    graph.show()
    graph.pack()
    # but1 = tk.Button(f0, text='Show Voxel Build', height=1, width=15, command= lambda: show_vox_build())
    # but1.pack(side=tk.RIGHT)
    # f0_area.create_window(10,10, window=but1)

    GUI.mainloop()
    # -------------------------------------------------------------
项目:ugm-kayu-nde    作者:mappuji    | 项目源码 | 文件源码
def create_app_graph(self):
        """ Create app graph
        """
        self.graph_figure = Figure(figsize=(4.4, 2.8), dpi=100)
        self.graph = FigureCanvasTkAgg(self.graph_figure, master=self.frame_top)
        self.graph.get_tk_widget().pack(side=LEFT, expand=NO, anchor=NW)
        # EMBED GRAPH TOOLBAR
        self.graph_toolbar = NavigationToolbar2TkAgg(self.graph, self.frame_bottom).pack(side=LEFT)
        # PLOT STARTING PLOT
        self.subplot = self.graph_figure.add_subplot(111)
        self.lines = self.subplot.plot([1, 2, 3], [1, 2, 3])
        self.change_xy_label('t(s)', 'magnitude')
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def __loadMatplotlib(self):
        global FigureCanvasTkAgg, Figure

        if FigureCanvasTkAgg is None:
            try:
                from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg
                from matplotlib.figure import Figure
            except:
                FigureCanvasTkAgg = Figure = False
项目:BeachedWhale    作者:southpaw5271    | 项目源码 | 文件源码
def addPlot(
            self,
            title,
            t, s,
            row=None,
            column=0,
            colspan=0,
            rowspan=0):
        self.__verifyItem(self.n_plots, title, True)

        self.__loadMatplotlib()
        if FigureCanvasTkAgg is False:
            raise Exception("Unable to load MatPlotLib - plots not available")
        else:
            fig = Figure()

            axes = fig.add_subplot(111)
            axes.plot(t,s)

            canvas = FigureCanvasTkAgg(fig, self.__getContainer())
            canvas.fig = fig
            canvas.axes = axes
            canvas.show()
    #        canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)
            canvas._tkcanvas.pack(side=TOP, fill=BOTH, expand=1)

            self.__positionWidget(canvas.get_tk_widget(), row, column, colspan, rowspan)
            self.n_plots[title] = canvas
            return axes
项目:CTPAPI    作者:doubleelforbes    | 项目源码 | 文件源码
def drawgraph(markethistory):
    global graphdrawn
    # Set up a graph and data sets
    timeplots = []
    priceplots = []
    # Set up the graph
    figgraph = Figure(figsize=(10, 10), dpi=60)
    # 2D Graph : 1 column, 1 Row, 1 Plot
    axes = figgraph.add_subplot(111)
    for key in markethistory:
        figgraph.suptitle(markethistory[key].Label)
        price = markethistory[key].Price
        timestamp = markethistory[key].Timestamp
        dtplot = datetime.datetime.fromtimestamp(timestamp)
        timeplots.insert(len(timeplots), dtplot)
        priceplots.insert(len(priceplots), price)
    # Enforce 8 decimal places
    axes.yaxis.set_major_formatter(FormatStrFormatter('%.8f'))
    # Plot the graph
    axes.plot(timeplots, priceplots)
    # Canvas placed in main frame, controlled by figgraph
    window.canvas = FigureCanvasTkAgg(figgraph, master=window.mainframe)
    window.canvas.get_tk_widget().place(relx=0.26, rely=0.01, relheight=0.46, relwidth=0.74)
    window.canvas.draw()
    graphdrawn = True


# Sell order list select event.
项目:hackathonAguas    作者:gabrielkirsten    | 项目源码 | 文件源码
def plotarGraficos(self):
        print "Gerando gráficos..."
        fig = plt.figure(1)                             # cria um vetor de figuras para serem exibidos os gráficos
        self.mainContainerPressao = Frame(self.frame_aba1, relief=RAISED, borderwidth=1)
        self.mainContainerPressao.pack(expand="true", fill="both", side="top")
        self.mainContainerCondutancia = Frame(self.frame_aba3, relief=RAISED, borderwidth=1)
        self.mainContainerCondutancia.pack(expand="true", fill="both", side="top")  

        for i in range(1, 7):
            for j in range(i+1, 7):
                aux = pearson_def(self.valor[i], self.valor[j]) 
                if aux < 97:
                    self.msgAlerta.config(text="Anomalia na coorelação entre " + str(self.descricao[i]) + " e " + str(self.descricao[j]) + "\n")
                    self.msgAlerta.pack()           


        for i in range(1, 7):                       # adiciona os gráficos no vetor
            plot = plt.subplot(230+i)
            plt.title(str(self.descricao[i]), fontsize=11)
            plot.tick_params(axis='both', which='major', labelsize=6)
            plot.tick_params(axis='both', which='minor', labelsize=7)
            tempLim = savgol_filter(self.valor[i], 27, 2)   # aplica o filtro de Savitzky-Golay
            # A linha abaico comentada apresenta junto com a linha de dados do gráfico, os limiares superiores e inferiores aceitaveis calculados pelo filtro de Savitzky-Golay, esta função se encontra em testes 
            #plt.plot(self.data_mensagem[i], self.valor[i], 'r', self.data_mensagem[i], [x + 0.25*x for x in tempLim], 'b',  self.data_mensagem[i], [x - 0.25*x for x in tempLim], 'b', linewidth=1.0)
            plt.plot(self.data_mensagem[i], self.valor[i], 'r', linewidth=1.0)
            plt.grid(True)

        canvas = FigureCanvasTkAgg(fig, master=self.mainContainerPressao)
        plot_widget = canvas.get_tk_widget().pack(side='top', fill='both', expand='true')

        fig = plt.figure(2) 
        for i in range(7, 8):                       # adiciona os gráficos no vetor
            plt.title(str(self.descricao[i]), fontsize=11)
            tempLim = savgol_filter(self.valor[i], 27, 2)   # aplica o filtro de Savitzky-Golay
            plt.plot(self.data_mensagem[i], self.valor[i], 'r', linewidth=1.0)
            plt.grid(True)

        canvas = FigureCanvasTkAgg(fig, master=self.mainContainerCondutancia)
        plot_widget = canvas.get_tk_widget().pack(side='top', fill='both', expand='true')

    # Método para conexão com o banco de dados
项目:PIEFACE    作者:jcumby    | 项目源码 | 文件源码
def updateplot(self, ellipsoid, title=None, **kwargs):
        if ellipsoid is None:
            self.figure = matplotlib.figure.Figure()
            self.canvas = FigureCanvasTkAgg(self.figure, master=self.parent)
            self.canvas.show()
        else:
            self.figure.clf()
            ellipsoid.plotsummary(figure=self.figure, title=title, pointcolor=kwargs.get('pointcolor', 'r'))
            #self.figure.canvas.draw()
            self.canvas.show()
项目:ScaleHack    作者:Miceuz    | 项目源码 | 文件源码
def __init__(self, master, figsize=(9, 6)):
        tk.Frame.__init__(self, master)
        self.figure = Figure(figsize=figsize)
        self.canvas = FigureCanvasTkAgg(self.figure, master=self)
        self.canvas.show()
        self.canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
        self.toolbar = NavigationToolbar2TkAgg(self.canvas, self)
        self.toolbar.update()
项目:Miniprojects    作者:Ivy-Coding-Camp    | 项目源码 | 文件源码
def __init__(self, parent, controller, number_of_months, balances, interests, principals):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        label = tk.Label(self, text="Mortgage Visualization", font=LARGE_FONT)
        label.pack(pady=10,padx=10)

        Button(self, text="Back", command=lambda: controller.show_frame(InputPage)).pack()

        months = list()

        i = 1
        while i <= number_of_months:
            months.append(i)
            i = i + 1

        f = Figure()
        f.subplots_adjust(left=0.15, right=0.95, wspace=0.25, hspace=0.75)
        a = f.add_subplot(211)
        plot1, = a.plot(months, interests,'r')
        plot2, = a.plot(months, principals,'g')

        b = f.add_subplot(212)
        plot3 = b.plot(months, balances, 'b')

        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)
项目:gmc    作者:kapilgarg1996    | 项目源码 | 文件源码
def plot (self, filepath):
        if self.prediction is not None:
            self.prediction.destroy()
        if self.canvas is not None:
            self.canvas.destroy()
        fig = msp(filepath)
        canvas = FigureCanvasTkAgg(fig, master=self.root)
        self.canvas = canvas.get_tk_widget()
        self.canvas.grid(row=0, column=0)
        canvas.draw()
项目:sds011    作者:luetzel    | 项目源码 | 文件源码
def __init__(self, master):
            frame = Frame(master)
            frame.pack()
            Label(frame, text="PM 2.5: ").grid(row=0, columnspan=2)
            Label(frame, text="µg/m^3: ").grid(row=0, column=3)
            Label(frame, text="PM  10: ").grid(row=1, columnspan=2)
            Label(frame, text="µg/m^3: ").grid(row=1, column=3)

            self.result_pm25 = DoubleVar()
            Label(frame, textvariable=self.result_pm25).grid(row=0, column=2)

            self.result_pm10 = DoubleVar()
            Label(frame, textvariable=self.result_pm10).grid(row=1, column=2)

            button0 = Button(frame, text="Start", command=self.sensor_wake)
            button0.grid(row=2, column=0)

            button1 = Button(frame, text="Stop", command=self.sensor_sleep)
            button1.grid(row=2, column=1)

            button2 = Button(frame, text="Read", command=self.sensor_read)
            button2.grid(row=2, column=2)

            button3 = Button(frame, text="Record", command=self.sensor_live)
            button3.grid(row=2, column=3)

            button4 = Button(frame, text="Quit", command=self.quit)
            button4.grid(row=2, column=4)

            #Label(frame, text="").grid(row=3, column=3)

            fig = pylab.Figure()
            self.canvas = FigureCanvasTkAgg(fig, master=master)
            self.canvas.show()
            self.canvas.get_tk_widget().pack(side=TOP, fill=BOTH, expand=1)

            self.ax = fig.add_subplot(111)
            self.ax.grid(True)
            self.ax.set_title("PM2.5 and PM10")
            self.ax.set_xlabel("Time (seconds)")
            self.ax.set_ylabel("PM (ug/m^3)")
            self.ax.axis([0,300,0,60])

        # 0xAA, 0xB4, 0x06, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0x06, 0xAB