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


Python FigureCanvasGTKAgg.draw方法代码示例

本文整理汇总了Python中matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg.draw方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasGTKAgg.draw方法的具体用法?Python FigureCanvasGTKAgg.draw怎么用?Python FigureCanvasGTKAgg.draw使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg的用法示例。


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

示例1: Plotter

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class Plotter(gtk.VBox):
    def __init__(self, xlabel, ylabel, width=500, height=500, dpi=75):
        """
        :type xlabel: str
        :type ylabel: str
        :type width: int
        :type height: int
        :type dpi: int
        """
        gtk.VBox.__init__(self)
        figure = Figure(figsize=(width, height), dpi=dpi)
        self.axes = figure.add_subplot(111, xlabel=xlabel, ylabel=ylabel)
        """ :type: matplotlib.axes.Axes """
        self.axes.hold(False)
        self.canvas = FigureCanvas(figure)
        #self.canvas.mpl_connect('button_press_event', self.klick)
        nav = NavigationToolbar(self.canvas, self)
        self.pack_start(nav, False, False)
        self.pack_start(self.canvas)

    def leeren(self):
        self.axes.hold(False)

    def plot(self, x, y, **args):
        self.axes.plot(x, y, antialiased=True, **args)
        self.axes.hold(True)

    def draw(self):
        self.canvas.draw()

    """def klick(self, evt):
开发者ID:lustra,项目名称:SpeckView,代码行数:33,代码来源:Plotter.py

示例2: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class Display:
    """ This class is responsible for rendering the graph in the upper portion
    of the window.  The data in the graph is taken from a Simulation object,
    which is accessed through the main Interface object. """

    # This is a color I chose to perfectly match the background of the rest of
    # the interface.  It might only work on my computer.
    # Malingo: Yes, it only works on your computer. It depends on what gtk
    # theme the user has chosen.
    background = "#edecea"

    def __init__(self, main):
        self.main = main

        pi = numpy.pi
        self.abscissa = numpy.arange(-pi - .25, pi + 0.25, 0.01)

        self.curve = None
        self.canvas = None

    def setup(self, layout):
        """ This method creates the graph that is displayed on the top half of
        the user interface.  Currently, the axes are completely hard-coded in
        this method and cannot be changed on-the-fly. """

        figure = Figure(facecolor=Display.background)
        axes = figure.add_subplot(111)

        # In order to create a line object, a dummy line needs to be plotted.
        # This line will get replaced before the GUI is shown to the user.
        pi = numpy.pi
        x = y = self.abscissa

        self.curve = axes.plot(x, y)[0]
        self.canvas = FigureCanvasGTKAgg(figure)

        # The tick labels are formatted using LaTeX.  This makes it possible
        # to use symbols like pi.
        axes.set_xticks((-pi, 0, pi))
        axes.set_xticklabels((r"-\pi", "0", r"\pi"))
        axes.set_xlim(-pi - 0.25, pi + 0.25)

        axes.set_yticks((0, 1))
        axes.set_yticklabels(("0", "1"))
        axes.set_ylim((-0.1, 1.1))

        layout.pack_start(self.canvas)

    def update(self):
        """ This method updates the graph using the new ordinate values
        returned by the simulation. """

        main = self.main
        simulation = main.simulation
        ordinate = simulation.plot(self.abscissa)

        self.curve.set_ydata(ordinate)
        self.canvas.draw()
开发者ID:Malingo,项目名称:DoubleSlit,代码行数:60,代码来源:interface.py

示例3: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class aacxGui:
	def __init__(self):
		self.builder = gtk.Builder()
		self.builder.add_from_file("aacx.ui")
		self.window = self.builder.get_object("window1")
		self.status = self.builder.get_object("statusbar1")
		self.frmadj = self.builder.get_object("frame_adj")
		self.about  = gtk.AboutDialog()

		self.about.set_name("AACX")
		self.about.set_version("0.0.1")
		self.about.set_copyright(u'Copyright © 2010 Alex Converse')
		self.about.set_website("http://github.com/aconverse/aacx")
		self.about.set_license("GPLv2+")

		self.window.connect("destroy", gtk.main_quit)
		signals = {
			"on_file_quit_activate": gtk.main_quit,
			"on_help_about_activate": self.show_about,
			"on_frame_adj_value_changed": self.spinback,
		}
		self.builder.connect_signals(signals)
		self.set_status_here("xxx")
		self.hasplot = 0
	def addplot(self, fig):
		self.canvas = FigureCanvasGTKAgg(fig)
		self.canvas.show()
		v = self.builder.get_object("vbox1")
		v.pack_start(self.canvas)
		self.hasplot = 1
	def redraw(self):
		self.canvas.draw()
	def show(self):
		self.window.show()
	def show_about(self, data):
		self.about.run()
		self.about.hide()
	def set_status_here(self, text):
		self.status.push(0, text)
	def spinback(self, data):
		spinback(int(data.get_value()), int(data.get_upper())+1)
	def set_spinner(self, n):
		self.frmadj.set_value(n)
	def set_num_frames(self, n):
		self.frmadj.set_upper(n-1)
开发者ID:aconverse,项目名称:aacx,代码行数:47,代码来源:aacx.py

示例4: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
    def __init__(self, toolBoxWidgets=None, title="GTK Gui Plot", scaling=True, *args, **kwargs):
        if not toolBoxWidgets:
            toolBoxWidgets = []
        super(GuiWithCanvasAndToolbar, self).__init__(*args, **kwargs)
        self.connect("destroy", lambda x: gtk.main_quit())
        self.set_default_size(1100, 600)
        self.set_title(title)

        table = gtk.Table(1, 2, False)

        self.figures = []
        self.y_max = float("-inf")
        self.x_max = float("-inf")
        self.y_min = float("inf")
        self.x_min = float("inf")
        self.fig = Figure(figsize=(8, 6), dpi=100)
        self.ax = self.fig.add_subplot(111)
        canvas = FigureCanvas(self.fig)
        canvas.set_size_request(800, 600)
        canvas.mpl_connect('button_press_event', self.handle_click)

        table.attach(canvas, 0, 1, 0, 1)

        toolbox = gtk.Table(len(toolBoxWidgets) + 1, 1, False)
        i = 0
        for widget in toolBoxWidgets:
            toolbox.attach(widget, 0, 1, i, i + 1)
            i += 1

        label = gtk.Label("SimGUI")
        toolbox.attach(label, 0, 1, i, i + 1)

        table.attach(toolbox, 1, 2, 0, 1)

        self.canvas = canvas
        canvas.draw()
        self.update_figures()

        self.add(table)
        self.scaling = scaling
开发者ID:salceson,项目名称:geometria,代码行数:42,代码来源:gui_with_canvas_and_toolbar.py

示例5: Reader

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class Reader(object):
    def __init__(self,win_size, win_loc, title,subplot_dim=[1,1]):
        self.top = gtk.Window()
        self.top.connect('delete-event', gtk.main_quit)
        self.top.set_title(title)
        self.top.set_position(gtk.WIN_POS_CENTER)
        self.top.set_default_size(*win_size)
        
        self.fig = Figure()
        
        self.axs = [self.fig.add_subplot(subplot_dim[0],
                                           subplot_dim[1],
                                           i+1) for i in
                    range(np.prod(subplot_dim))]
        self.canvas = FigureCanvas(self.fig)
        self.top.add(self.canvas)
        self.top.show_all()
        
        self.update_background()
        
        if len(self.axs) == 1:
            self.ax = self.axs[0]
            
        
    def update_background(self):
        self.canvas.draw()
        self.backgrounds = [self.canvas.copy_from_bbox(ax.bbox) for
                            ax in self.axs]
        if len(self.backgrounds) == 1: 
            self.background = self.backgrounds[0]
            
        
        return 
    
    def draw(self):
        raise Exception('Not implemented.')
    
    def read(self):
        raise Exception('Not implemented yet.')
开发者ID:joel-shor,项目名称:Context-Classifier,代码行数:41,代码来源:Reader.py

示例6: GTKFacePlot

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class GTKFacePlot (gtk.Window):
    def __init__(self):
        gtk.Window.__init__(self,gtk.WINDOW_TOPLEVEL)

        self.set_title("MixedEmotions")
        self.set_border_width(10)
        
        self.fig = Figure(figsize=(3,1), dpi=100)
        self.ax = self.fig.add_subplot(111)
        self.x = arange(0,2*pi,0.01)           # x-array
        self.lines = self.ax.plot(self.x,sin(self.x))
        self.canvas = FigureCanvas(self.fig)
        self.add(self.canvas)      

        self.figcount = 0
        gtk.timeout_add(100, self.updatePlot)

    def updatePlot(self):
        self.figcount += 1
        self.lines[0].set_ydata(sin(self.x+self.figcount/10.0))
        self.canvas.draw()
        return gtk.TRUE
开发者ID:BBelonder,项目名称:PyExpLabSys,代码行数:24,代码来源:example2.py

示例7: make_fig

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
 def make_fig(title = None):
     '''
     Create a figure window with a single set of axes and a single main subplot.
     Returns the axes of the main subplot
     '''
     global all_sub_figures
     if title == None:
         title = "Untitled Figure {0}".format(len(all_sub_figures)+1)
     dialog = gtk.Dialog(title, win, gtk.DIALOG_DESTROY_WITH_PARENT)
     dialog.set_default_size(500,400)
     fig = matplotlib.figure.Figure()
     axes = fig.add_subplot(111)
     #axes.invert_yaxis()
     #axes.autoscale()
     canvas = FigureCanvasGTKAgg(fig)  # a gtk.DrawingArea
     canvas.set_size_request(300,300)
     dialog.vbox.pack_start(canvas, expand=True)
     toolbar = NavigationToolbar2GTKAgg(canvas, dialog)
     dialog.vbox.pack_start(toolbar, False, False)
     dialog.show_all()
     canvas.draw()
     fig.prev_child_count = 0
     all_sub_figures.append(fig)
     return axes
开发者ID:bradenmacdonald,项目名称:astrocube,代码行数:26,代码来源:astrocubeview.py

示例8: LoggerPlot

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class LoggerPlot (gtk.VBox):

    def __init__ (self):
        gtk.VBox.__init__ (self)
        self.figure  = Figure(figsize=(5,4), dpi=100)
        self.canvas  = FigureCanvas (self.figure)
        self.toolbar = NavigationToolbar (self.canvas, None)

        self.pack_start (self.canvas)
        self.pack_start (self.toolbar, False, False)

        #FigureCanvas.__init__ (self, self.figure)

    def plot (self, title, x, y):
        self.figure.clear()
        a = self.figure.add_subplot(111)
        a.set_title (title)
        a.grid(True)
        a.plot(x,y)
        self.canvas.draw()

    def clear (self):
        self.figure.clear()
        self.canvas.draw()
开发者ID:chentianran,项目名称:hview,代码行数:26,代码来源:loggerplot.py

示例9: PopUpImage

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class PopUpImage(object):
	def __init__(self, xdata, ydata, xlabel, ylabel, title):
		self.popupwin=gtk.Window()
		self.popupwin.set_size_request(600,550)
		self.popupwin.set_position(gtk.WIN_POS_CENTER)
		self.popupwin.set_border_width(10)
		self.xdata = xdata
		self.ydata = ydata
		vbox = gtk.VBox()
		self.fig=Figure(dpi=100)
		self.ax  = self.fig.add_subplot(111)
		self.canvas  = FigureCanvas(self.fig)
		self.main_figure_navBar = NavigationToolbar(self.canvas, self)
		self.cursor = Cursor(self.ax, color='k', linewidth=1, useblit=True)
		self.canvas.mpl_connect("button_press_event",self.on_press)
		self.ax.set_xlabel(xlabel, fontsize = 18)
		self.ax.set_ylabel(ylabel, fontsize = 18)
		self.ax.set_title(title, fontsize = 18)
		self.ax.plot(self.xdata, self.ydata, 'b-', lw=2)
		
		self.textes = []
		self.plots  = []
		vbox.pack_start(self.main_figure_navBar, False, False, 0)
		vbox.pack_start(self.canvas, True, True, 2)
		self.popupwin.add(vbox)
		self.popupwin.connect("destroy", self.dest)
		self.popupwin.show_all()
	
	def dest(self,widget):
		self.popupwin.destroy()
	
	def on_press(self, event):
		if event.inaxes == self.ax and event.button==3:
			self.clear_notes()
			xc = event.xdata
			#***** Find the closest x value *****
			residuel = self.xdata - xc
			residuel = N.abs(residuel)
			j = N.argmin(residuel)
			#y = self.ydata[i-1:i+1]
			#yc= y.max()
			#j = N.where(self.ydata == yc)
			#j = j[0][0]
			xc= self.xdata[j]
			x_fit = self.xdata[j-3:j+3]
			y_fit = self.ydata[j-3:j+3]
			fitted_param, fitted_data = fit(x_fit, y_fit, xc, True)
			x_fit = N.linspace(x_fit.min(), x_fit.max(), 200)
			y_fit = psdVoigt(fitted_param, x_fit)
			period = fitted_param['xc'].value
			std_err= fitted_param['xc'].stderr
			
			p = self.ax.plot(x_fit, y_fit,'r-')
			p2 = self.ax.axvline(period,color='green',lw=2)
			
			txt=self.ax.text(0.05, 0.9, 'Period = %.4f +- %.4f (nm)'%(period, std_err), transform = self.ax.transAxes, color='red')
			self.textes.append(txt)
			self.plots.append(p[0])
			self.plots.append(p2)
		elif event.inaxes == self.ax and event.button==2:
			dif = N.diff(self.ydata)
			dif = dif/dif.max()
			p3  = self.ax.plot(dif,'r-')
			self.plots.append(p3[0])
		self.canvas.draw()
	
	def clear_notes(self):
		if len(self.textes)>0:
			for t in self.textes:
				t.remove()
		if len(self.plots)>0:
			for p in self.plots:
				p.remove()
		self.textes = []
		self.plots  = []
开发者ID:santoshpanda15,项目名称:DEVA,代码行数:77,代码来源:PopUpWindows.py

示例10: Iverplot_window

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class Iverplot_window (object):
    """
    Iverplot_window---main Iverplot GUI object

    Parameters
    -----------

    Notes
    ------

    """
    def __init__ (self):
        self.builder = gtk.Builder ()
        self.builder.add_from_file ('iverplot.glade')
        self.builder.connect_signals (self)
        self.window = self.builder.get_object ('main_window')

        # add matplotlib figure canvas
        w,h = self.window.get_size ()
        self.fig = Figure (figsize=(6,4))
        self.canvas = FigureCanvas (self.fig)  # a gtk.DrawingArea
        self.canvas.set_size_request (w-150,-1)

        vbox = gtk.VBox()
        toolbar = NavigationToolbar (self.canvas, self.window)
        vbox.pack_start (self.canvas, True, True)
        vbox.pack_start (toolbar, False, False)

        # a little hacky for packing hpane with figure canvas first then tool
        # bar---not sure if glade is to blame---first, remove tool_vbox then
        # repack
        plot_hpaned = self.builder.get_object ('plot_hpaned')
        self.tool_vbox = self.builder.get_object ('tool_vbox')
        plot_hpaned.remove (self.tool_vbox)

        #plot_hpaned.pack1 (self.canvas, resize=True, shrink=False)
        plot_hpaned.pack1 (vbox, resize=True, shrink=False)
        plot_hpaned.pack2 (self.tool_vbox)

        # data
        self.uvclog = None
        self.lcmlog = None

        # plot limits
        self.xlimits = [None,None]
        self.xlimits_abs = [None,None]

        # add single plot item
        self.plotdex = {}
        self.plot_items = []
        self.plot_items.append (Plot_item (self.tool_vbox,
            self.on_plot_item_selected, self.uvclog, self.lcmlog))
        self.update_subplots ()

        # setwin
        self.setwin = None

        # set some defaults
        self.cd_saveas = os.getcwd ()
        self.cd_open = os.getcwd ()

        self.window.show_all ()

    def on_setwin_clicked (self, widget):
        if self.setwin is None: 
            self.setwin = Setwin (self.canvas, self.fig, self.on_setwin_complete)

    def on_setwin_complete (self, xmin, xmax):
        self.xlimits = [xmin,xmax]
        for p in self.plot_items:
            ax = self.fig.axes[self.plotdex[p]]
            p.plot_type.set_limits (ax, *self.xlimits)
        self.canvas.draw ()
        self.setwin = None

    def on_setwin_reset (self, widget):
        if not self.setwin is None: return
        self.xlimits = [x for x in self.xlimits_abs]
        for p in self.plot_items:
            ax = self.fig.axes[self.plotdex[p]]
            p.plot_type.set_limits (ax, *self.xlimits)
        self.canvas.draw ()

    def update_subplots (self):
        self.fig.clear ()
        n = len (self.plot_items)
        for i,p in enumerate (self.plot_items):
            p.plot_type.uvclog = self.uvclog
            p.plot_type.lcmlog = self.lcmlog
            ax = self.fig.add_subplot (n,1,i+1)
            p.plot_type.plot (ax, *self.xlimits)
            self.plotdex[p] = i
        self.canvas.draw ()

    def on_plot_item_selected (self, combo, item):
        ax = self.fig.axes[self.plotdex[item]]
        item.plot_type.plot (ax, *self.xlimits)
        self.canvas.draw ()

    def update_window (self):
#.........这里部分代码省略.........
开发者ID:jmwalls,项目名称:iverplot,代码行数:103,代码来源:iverplot.py

示例11: makewin

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]

#.........这里部分代码省略.........
            print chanlocs.shape

        #xi, yi = mgrid[-.5:.5:67j,-.5:.5:67j]
        xi, yi = mgrid[chanlocs[1,:].min():chanlocs[1,:].max():57j,chanlocs[0,:].min():chanlocs[0,:].max():57j]
        intx=chanlocs[1,:]
        inty=chanlocs[0,:]

        if shape(shape(data))[0]==2: #more than a single vector, need to animate or subplot

            print '2d array of data'
            z = data[0,:]
            if delaunay == 'yes':
                print 'delaunay is set'
                tri = Triangulation(intx,inty)
                interp = tri.nn_interpolator(z)
                zi = interp(xi,yi)
            else: #try griddata method
                print 'delaunay is off'
                zi = griddata(intx,inty,z,xi,yi)


            if animate == 'on': #single plot with a loop to animate
                p.scatter(intx,inty, alpha=.5,s=.5)
                print 'animating'
                for i in range(0, shape(data)[0]):
                    dataslice=data[i,:];
                    z = dataslice
                    if delaunay == 'yes':
                        interp = tri.nn_interpolator(z)
                        zi = interp(xi,yi)
                    else:
                        zi = griddata(intx,inty,z,xi,yi)

                    zim = ma.masked_where(isnan(zi),zi)
                    p.contourf(xi,yi,zim,cmap=p.cm.jet, alpha=.8)
                    if labels != None:
                        printlabels(chanlocs, labels)
                    p.draw()
            if subplot == 'on':
                print 'suplotting'
                for i in range(0, shape(data)[0]):
                    spnum = ceil(sqrt(shape(data)[0])) #get x and y dimension of subplots
                    #self.p = f.add_subplot(spnum,spnum,i+1)
                    self.p = self.f.add_subplot(spnum,spnum,i+1);#axis('off')
                    dataslice=data[i,:];
                    self.p.scatter(intx,inty, alpha=.75,s=3)
                    z = dataslice
                    if delaunay == 'yes':
                        interp = tri.nn_interpolator(z)
                        zi = interp(xi,yi)
                    else:
                        zi = griddata(intx,inty,z,xi,yi)

                    zim = ma.masked_where(isnan(zi),zi)
                    self.p.contourf(xi,yi,zim,cmap=cm.jet, alpha=.8)
                    self.p.axis('off')
                    if labels != None:
                        printlabels(chanlocs, labels)
                    if title != None:
                        self.p.title(str(title[i]))
                    else:
                        pass
                        #self.p.title(str(i))
            if quiver == 'on':
                print 'suplotting quiver'
                for i in range(0, shape(data)[0]):
                    spnum = ceil(sqrt(shape(data)[0])) #get x and y dimension of subplots
                    fig.add_subplot(spnum,spnum,i+1);#axis('off')
                    dataslice=data[i,:];
                    p.scatter(intx,inty, alpha=.75,s=3)
                    z = dataslice
                    print 'size or z', size(z)
                    for xx in range(0,size(z)):
                        quiver(intx[xx],inty[xx], z[xx], data2[xx])

                    p.axis('off')
                    if labels != None:
                        printlabels(chanlocs, labels)
            if colorbar == 'on':
                p.colorbar()

        else:
            z = data
            if delaunay == 'yes':
                print 'delaunay is set'
                tri = Triangulation(intx,inty)
                interp = tri.nn_interpolator(z)
                zi = interp(xi,yi)
            else:
                print 'delaunay is off'
                zi = griddata(intx,inty,z,xi,yi)

            zim = ma.masked_where(isnan(zi),zi)
            self.plot_data(xi,yi,zi,intx,inty)
            if labels != None:
                printlabels(chanlocs, labels)

            if colorbar == 'on':
                p.colorbar(cm)
        self.canvas.draw()
开发者ID:badbytes,项目名称:pymeg,代码行数:104,代码来源:megcontour_gtk.py

示例12: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]

#.........这里部分代码省略.........
          total_list=[0]
          counter=0 
          for i in model:
            for j in i:
              counter+=1
              if counter%7==0:
                total_list.append(j)
              #print j, type(j),
            #print '\n' 
          #print range(len(total_list))
          #print total_list
          if max(total_list)==0:
            M=1
          else:
            M=max(total_list)+0.1*max(total_list)
          self.a.set_ylim(0,M)
          self.a.set_xlim(1,len(total_list)-1)
          days=[]
          for i in range(len(total_list)):
            if i%2!=0:
              days.append(i)
          self.a.set_xticks(days)
          self.a.set_xticklabels(days,fontsize=9)
          
          #print total_list, len(total_list)        
          #total_list.append(100)
          while len(self.line1)!=0:
            l=self.line1.pop(0)
            l.remove()
          total_list.append(0)
          #self.a.set_antialiased(False)
          #print total_list
          self.line1=self.a.fill(total_list,'blue',alpha=0.6)
          self.canvas.draw()
          
        
          #print line
          
          
          self.b=self.f.add_subplot(222)
          self.b.patch.set_color('black')
          self.b.patch.set_alpha(0.05)
          self.b.yaxis.grid('True')
          self.b.set_xlabel('Categories',fontsize=12)
          self.b.set_ylabel('Category Expense',fontsize=12)
          total_list=[0]
          counter=0
          #print 1
          stats.update(self.fname)
          counter=0
          cat=[]
          for i in stats.create_model(self):
            for j in i:
              counter+=1
              if counter%2==0:
                total_list.append(j)
              else:
                cat.append(j)
          
          del total_list[-1]
          del cat[-1]
          #print cat
          #print total_list
          #print 'sfdf'
          if max(total_list)==0:
            M=1
开发者ID:Isendir,项目名称:Expense-Manager,代码行数:70,代码来源:main.py

示例13: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]

#.........这里部分代码省略.........
        elif call=="splitcontour":
            self.setClickMode("splitcontour")
        elif call=="cropimage":
            self.setClickMode("crop1")
        elif call=="getdigitsize":
            self.setClickMode("getdigit1")
        elif call=="tagokbtn":
            self.curtag=self.builder.get_object("tagname").get_text()   
            self.builder.get_object("tagwindow").set_visible(0)   
            self.contours.append(Contour(self.tempditem,self.tempitem,self.curtag))
            if not (self.d1size in self.dsizes):
                self.dsizes.append(self.d1size)
        elif call=="tagcancelbtn":
            self.setClickMode("none")
            self.builder.get_object("tagwindow").set_visible(0)
        elif call=="trnext":
            self.trNext()

        elif call=="trprev":
            if self.trframe>0:
                self.trframe-=1
                self.updateTrainingDataWindow()
        elif call=="savetrdata":
            fn=self.builder.get_object("trfile").get_text()
            f=open(fn, "w")
            pickle.dump(self.traindict, f)
            f.close()
        elif call=="allconts":
            #show all contours in monitor config window
            self.loadMonitorImage(self.builder.get_object("monitorconfigloadfile").get_filename(), allconts=True)
            
        elif call=="clearunsaved":
            #redraw only those ritems in self.contours
            self.drawMonitor(clearunsaved=True)
            
        elif call=="liverecord":
            #TODO test? Fix all parameters here
            #start loop to get data
            fn=self.builder.get_object("livefile").get_text()
            f=open(fn,"r")
            #log to f

            while True:
                self.livelist=[]
                #get image using current camera config
                ret,im=self.cap.read()
                #run contour detection
                (self.monimage,self.dlist,self.rlist)=self.getContours(a,self.d1size)
                #take only labelled ones
                for i in range(len(self.rlist)):
                    for j in range(len(self.contours)):
                        #if self.rlist[i]==cont.ritem:
                        #TODO remove hidden parameters here
                        cont=self.contours[j]
                        if np.abs(self.rlist[i][0][0]-cont.ritem[0][0])<=4 and np.abs(self.rlist[i][0][1]-cont.ritem[0][1])<=4:
                            #Need to append x position, label
                            self.livelist.append((self.dlist[i],j))
                    #could add width, height check as well
                
                #run digit analysis
                #TODO - modify this for known number of digits?
                for item2 in self.livelist:
                    item=item2[0][0]
                    q=False
                    #data = np.zeros((esize), dtype=np.uint8)
                    esize1=self.d1size[0]*self.d1size[1]
开发者ID:jamesmcm,项目名称:MLTest,代码行数:70,代码来源:gui.py

示例14: band_graph

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class band_graph(gtk.VBox):
	def init(self):

		toolbar = gtk.Toolbar()

		toolbar.set_style(gtk.TOOLBAR_ICONS)
		toolbar.set_size_request(-1, 50)
		self.pack_start(toolbar, False, False, 0)

		tool_bar_pos=0
		save = gtk.ToolButton(gtk.STOCK_SAVE)
		save.connect("clicked", self.callback_save_image)
		toolbar.insert(save, tool_bar_pos)
		toolbar.show_all()
		tool_bar_pos=tool_bar_pos+1

		self.my_figure=Figure(figsize=(5,4), dpi=100)
		self.canvas = FigureCanvas(self.my_figure)  # a gtk.DrawingArea
		self.canvas.figure.patch.set_facecolor('white')
		self.canvas.set_size_request(600, 400)
		self.canvas.show()
		self.pack_start(self.canvas, False, False, 0)

		self.canvas.connect('key_press_event', self.on_key_press_event)

		self.show_all()

	def on_key_press_event(self,widget, event):
		keyname = gtk.gdk.keyval_name(event.keyval)
		if keyname == "c":
			if event.state == gtk.gdk.CONTROL_MASK:
				self.do_clip()

		self.canvas.draw()

	def do_clip(self):
		print "doing clip"
		snap = self.my_figure.canvas.get_snapshot()
		pixbuf = gtk.gdk.pixbuf_get_from_drawable(None, snap, snap.get_colormap(),0,0,0,0,snap.get_size()[0], snap.get_size()[1])
		clip = gtk.Clipboard()
		clip.set_image(pixbuf)

	def callback_save_image(self, widget):
		dialog = gtk.FileChooserDialog("Save plot",
                               None,
                               gtk.FILE_CHOOSER_ACTION_SAVE,
                               (gtk.STOCK_CANCEL, gtk.RESPONSE_CANCEL,
                                gtk.STOCK_SAVE, gtk.RESPONSE_OK))
		dialog.set_default_response(gtk.RESPONSE_OK)
		dialog.set_action(gtk.FILE_CHOOSER_ACTION_CREATE_FOLDER)

		filter = gtk.FileFilter()
		filter.set_name("png")
		filter.add_pattern("*.png")
		dialog.add_filter(filter)

		response = dialog.run()
		if response == gtk.RESPONSE_OK:
			self.my_figure.savefig(dialog.get_filename())

		elif response == gtk.RESPONSE_CANCEL:
		    print 'Closed'
		dialog.destroy()

	def set_data_file(self,file):
		self.optical_mode_file=os.path.join(os.getcwd(),"light_dump",file)

	def draw_graph(self):
		self.layer_end=[]
		self.layer_name=[]

		n=0
		self.my_figure.clf()
		ax1 = self.my_figure.add_subplot(111)
		ax2 = ax1.twinx()
		x_pos=0.0
		layer=0
		color =['r','g','b','y','o','r','g','b','y','o']
		start=0.0

		for i in range(0,epitaxy_get_layers()):
			if epitaxy_get_electrical_layer(i)=="none":
				start=start-epitaxy_get_width(i)
			else:
				break
		print "START=",start
		start=start*1e9

		x_pos=start
		for i in range(0,epitaxy_get_layers()):

			label=epitaxy_get_mat_file(i)
			layer_ticknes=epitaxy_get_width(i)
			layer_material=epitaxy_get_mat_file(i)

			delta=float(layer_ticknes)*1e9
			if epitaxy_get_electrical_layer(i)=="none":
				mat_file=os.path.join(os.getcwd(),'materials',layer_material,'mat.inp')
				myfile = open(mat_file)
				self.mat_file_lines = myfile.readlines()
#.........这里部分代码省略.........
开发者ID:roderickmackenzie,项目名称:opvdm,代码行数:103,代码来源:band_graph.py

示例15: __init__

# 需要导入模块: from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg [as 别名]
# 或者: from matplotlib.backends.backend_gtkagg.FigureCanvasGTKAgg import draw [as 别名]
class FeedbackApp:

    def __init__(self):
        # initialize the feedbackloop
        gtk.threads_init()
        gtk.threads_enter()
        self.feedbackloop = feedbackLoop()
        self.feedbackloop.active = False
        self.feedbackloop.start()
        gtk.threads_leave()

        # create a window
        self.win = gtk.Window(gtk.WINDOW_TOPLEVEL)
        self.win.set_size_request(600,500)
        self.win.connect('destroy', gtk.main_quit)

        #vbox to put everything in
        self.vbox = gtk.VBox()
        self.win.add(self.vbox)

        # add a graph
        self.figure = Figure(figsize=(10,4))
        self.figureCanvas = FigureCanvas(self.figure)
        self.vbox.pack_start(self.figureCanvas, expand=True, fill=True)

        # graph
        self.axes = self.figure.add_subplot(111)
        self.axes.grid()

        self.line, = self.axes.plot([1,2,3,4,5],[5,3,5,2,5],'-^', label='output signal PID')

        # topline
        self.topline, = self.axes.plot([-1e99, 1e99], 2*[self.feedbackloop.max_signal], label='upper lim')
        self.botline, = self.axes.plot([-1e99, 1e99], 2*[self.feedbackloop.min_signal], label='lower lim')
        self.figureCanvas.draw()
        self.axes.legend(loc=2)


        # button start/stop
        self.buttonBox = gtk.HButtonBox()
        self.vbox.pack_end(self.buttonBox, expand=False, fill=True)

        self.startStopButton = gtk.ToggleButton('Start/Stop')
        self.startStopButton.connect('toggled', self.activateFeedbackLoop)
        self.buttonBox.pack_start(self.startStopButton)


        self.win.show_all()
        gobject.idle_add(self.update_graph)

    def activateFeedbackLoop(self, *args):
        """ Activate the feedbackloop """
        if self.startStopButton.get_active():
            print "ctivating feedback"
        self.feedbackloop.active = self.startStopButton.get_active()

        



    # add a start/stop box


    def update_graph(self):
        """ Update the graphical representation of the feedback loop"""
        xdata = self.feedbackloop.time_history.toArray()
        order = np.argsort(xdata)
        xdata = xdata[order]
        ydata = self.feedbackloop.signal_history.toArray()
        ydata = ydata[order]

        self.line.set_xdata(xdata)
        self.line.set_ydata(ydata)
        self.figureCanvas.draw()
        try:
            if not (None in xdata.tolist()):
                self.axes.set_xlim(min(xdata),max(xdata))
            else:
                self.axes.set_xlim(max(xdata)-20, max(xdata))
            self.axes.set_ylim(0,5)
        except:
            pass

        return True
开发者ID:dboonz,项目名称:TemperatureFeedback_Reprate,代码行数:86,代码来源:gui.py


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