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


Python FigureCanvasGTK.destroy方法代码示例

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


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

示例1: Backend

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class Backend( backend.Plotter ):

    def init(self):
        # line_cache: key = id(Curve), value=mpl line object
        self.line_cache = dict()
        
        self.layer_to_axes = dict()
        self.axes_to_layer = dict()
        self.layers_cache = list() # copy of self.plot.layers
        
    def connect(self):
        logger.debug("Opening matplotlib session.")        

        self.figure = Figure(dpi=100, facecolor="white")  # figsize=(5,4), dpi=100)        
        self.canvas = FigureCanvas(self.figure)
        self.canvas.show()

        self.line_cache.clear()
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()

        backend.Plotter.connect(self)
        logger.debug("Init finished")


    def disconnect(self):
        logger.debug("Closing matplotlib session.")

        if not self.canvas is None:
            self.canvas.destroy()
            self.canvas = None
        if not self.figure is None:
            self.figure = None
        
        backend.Plotter.disconnect(self)


    #----------------------------------------------------------------------

    def arrange(self, rows=1, cols=1):

        layers = self.plot.layers
        n = len(layers)

        if n > (rows*cols):
            rows = int((rows*cols) / n) + 1
            cols = rows * n
            #raise ValueError("Not enough rows and cols for all layers!")

        self.figure.clear()
        self.figure.axes = []
        
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()
        self.layers_cache = list()
        j = 1
        for layer in layers:
            print "Setting up layer", layer
            axes = self.figure.add_subplot("%d%d%d" % (rows,cols,j))
            self.layer_to_axes[layer] = axes
            self.axes_to_layer[axes] = layer
            self.layers_cache.append(layer)
            j += 1
        

        
    def draw_layer(self, layer, group_info):

        ax = self.layer_to_axes[layer]

        print "DRAWING AXES ", ax
        ax.lines = []

        line_cache = []
        line_count = 0
        last_cx = -1

        # Default values come in two flavors:
        # group-wise and single default values        
        group_colors = uwrap.get(layer, 'group_colors')
        group_styles = uwrap.get(layer, 'group_styles')
        group_markers = uwrap.get(layer, 'group_markers')

        #default_color = 'r'
        default_color = None
        default_style = 'solid'
        default_marker = 'None'
        

        #:layer.visible
        if uwrap.get(layer, 'visible') is False:
            return

        #:layer.title
        title = uwrap.get(layer, 'title', None)
        if title is not None:
            ax.set_title(title)        

        #:layer.grid
        grid = uwrap.get(layer, 'grid')
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sloppyplot-svn,代码行数:103,代码来源:mpl.py

示例2: Backend

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class Backend( backend.Backend ):

    def init(self):
        
        self.layer_to_axes = {}
        self.axes_to_layer = {}
        self.layers_cache = [] # copy of self.plot.layers
        self.layer_signals = {}
        
        self.line_caches = {}
        self.omaps = {}
        
        
    def connect(self):
        logger.debug("Opening matplotlib session.")        

        self.figure = Figure(dpi=100, facecolor="white")  # figsize=(5,4), dpi=100)        
        self.canvas = FigureCanvas(self.figure)
        self.canvas.show()

        self.line_caches = {}
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()

        backend.Backend.connect(self)
        logger.debug("Init finished")


    def set(self, project,plot):
        backend.Backend.set(self, project, plot)
        if self.project is not None:
            # TODO: connect to notify::layers of Plot
            pass

    def disconnect(self):
        logger.debug("Closing matplotlib session.")

        if not self.canvas is None:
            self.canvas.destroy()
            self.canvas = None
        if not self.figure is None:
            self.figure = None
        
        backend.Backend.disconnect(self)

        

    #----------------------------------------------------------------------

    def arrange(self, rows=1, cols=1):

        layers = self.plot.layers
        n = len(layers)

        if n > (rows*cols):
            rows = int((rows*cols) / n) + 1
            cols = rows * n
            #raise ValueError("Not enough rows and cols for all layers!")

        self.figure.clear()
        self.figure.axes = []
        
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()
        self.layers_cache = []

        for signal_list in self.layer_signals.itervalues():
            for signal in signal_list:
                Signals.disconnect(signal)
        self.layer_signals = {}
        
        j = 1
        for layer in layers:
            print "Setting up layer", layer
            axes = self.figure.add_subplot("%d%d%d" % (rows,cols,j))
            self.layer_to_axes[layer] = axes
            self.axes_to_layer[axes] = layer
            self.layers_cache.append(layer)

            print "Connecting to notify of ", layer
            self.layer_signals[layer] = \
              [Signals.connect(layer, 'notify', self.on_update_layer),
               Signals.connect(layer, 'notify::labels', self.on_update_labels)]

            j += 1


    def draw(self):
        self.check_connection()
        logger.debug("Matplotlib: draw()")                
             
        if self.plot.layers != self.layers_cache:
            self.arrange()

        self.omaps = {}
        for layer in self.plot.layers:
            self.update_layer(layer)
        self.draw_canvas()
        
    def draw_canvas(self):
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sloppyplot-svn,代码行数:103,代码来源:mpl.py

示例3: GuiApp

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class GuiApp(object):

    def __init__(self):
	global unit
	self.filename=None
	self.gladefile="/usr/share/freeceilo-%s/ceilo.glade" % VERSION
       	self.wTree=gtk.glade.XML(self.gladefile)
       	self.window=self.wTree.get_widget("FreeCeilo")
       	self.window.maximize()

	self.threadvar=0
      #--------buttons---------#
	self.Open=self.wTree.get_widget("Open")
      #-----cloud detection plotting button------#
	self.first_cld_plot_button=self.wTree.get_widget("first_cld_plot_button")
	self.second_cld_plot_button=self.wTree.get_widget("second_cld_plot_button")
	self.third_cld_plot_button=self.wTree.get_widget("third_cld_plot_button")
	self.cld_det_clear_button=self.wTree.get_widget("cld_det_clear_button")
	self.cld_det_save_button=self.wTree.get_widget("cld_det_save_button")
		
      #------------  gnuplot buttons -------------#
	self.gnu_plot_button=self.wTree.get_widget("gnu_plot_button")			
	self.gnuplot_zoom_in_button=self.wTree.get_widget("gnuplot_zoom_in_button")
	self.gnuplot_zoom_normal_button=self.wTree.get_widget("gnuplot_zoom_normal_button")
	self.gnuplot_zoom_out_button=self.wTree.get_widget("gnuplot_zoom_out_button")	
	self.gnuplot_save_button=self.wTree.get_widget("gnuplot_save_button")

      #--------buttons ends---------#

      #------progressbars------#

	self.progressbar1=self.wTree.get_widget("progressbar1")

	self.progressbar2=self.wTree.get_widget("progressbar2")

        self.progressbar1.set_fraction(0.0)
	self.datpbar=0

        self.progressbar2.set_fraction(0.0)
	self.gnupbar=0

	self.timer = gobject.timeout_add (100, progress_timeout, self)

     #------gnu plot image normal size ----#

	self.imagex= 810
	self.imagey=540
	self.gnuplot_image=self.wTree.get_widget("gnuplot_image")
	self.x=0

     #--------Handles events



	dic={"on_FreeCeilo_destroy":self.quitprogram,"on_Open_activate":self.openfile,
	"on_first_cld_plot_button_clicked":self.firstcloudshow,"on_second_cld_plot_button_clicked"
	:self.secondcloudshow,"on_third_cld_plot_button_clicked":self.thirdcloudshow,	
	"on_zoom_in_x_activate":self.clouddetectzoominx,"on_zoom_out_x_activate":
	self.clouddetectzoomoutx,"on_zoom_in_y_activate":self.clouddetectzoominy,
	"on_zoom_out_y_activate":self.clouddetectzoomouty,"on_cld_det_save_button_clicked"
	:self.clouddetectsave,"on_cld_det_clear_button_clicked":self.clouddetectgraphclear,
	"on_gnu_plot_button_clicked":self.gnuplotshow,"on_gnuplot_zoom_in_button_clicked":
	self.gnuplotzoomin,"on_gnuplot_zoom_normal_button_clicked":self.gnuplotzoomnormal,
	"on_gnuplot_zoom_out_button_clicked":self.gnuplotzoomout,"on_gnuplot_save_button_clicked"
	:self.gnuplotsave}
        self.wTree.signal_autoconnect(dic)


     #-----plotting area for graphs
	
	self.graphview = self.wTree.get_widget("hbox7")

     #-----plotting area for cloud detection graph
 
       	self.figure1 = Figure(figsize=(12,6),facecolor='y',dpi=55,edgecolor='black',linewidth=5.0)
	self.axis1 = self.figure1.add_subplot(111)
	self.axis1.grid(True)

	self.canvas1 = FigureCanvasGTK(self.figure1)
	self.graphview.pack_start(self.canvas1,True,True)
        self.canvas1.show()
	self.axis1.set_autoscale_on(True)

    #-----plotting area for back scatterprofile

	self.figure2 = Figure(figsize=(12,6),facecolor='y', dpi=55,edgecolor='black',linewidth=4.0)
	self.axis2 = self.figure2.add_subplot(111)
	self.axis2.grid(True)
        self.canvas2 = FigureCanvasGTK(self.figure2) 
	self.graphview.pack_end(self.canvas2,True,True)
        self.canvas2.show()

################################# File Openning and dataprocessing #######################
    def openfile(self,obj):
	self.filename=None
	if(self.threadvar==1):
		os.system("killall -9 gnuplot > /dev/zero")
		self.datpbar=0
		self.gnupbar=0
		self.datadecode_thread_obj.stop()
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:freeceilo-svn,代码行数:103,代码来源:gui.py

示例4: __init__

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class Graphic:
    def __init__(self, widget):
        self.figure = Figure(figsize=(4,3), dpi=64)
        self.axes = self.figure.add_subplot(111) 
        self.axes.grid(True)
        self.widget = widget
        self.canvas = FigureCanvasGTK(self.figure)
        self.graphview = widget
        self.graphview.pack_start(self.canvas, True, True)

        #self.cursor = None
        #self.on_press_cb = None
        #self.on_release_cb = None
        #self.on_motion_cb = None
        self.lx_min = None
        self.lx_max = None
        #self.rec = None
        self.axes2 = None
        self.span = None
        
        self.ticklines = self.axes.get_xticklines()
        self.ticklines.extend( self.axes.get_yticklines() )
        self.gridlines = self.axes.get_xgridlines()
        self.gridlines.extend( self.axes.get_ygridlines() )
        self.ticklabels = self.axes.get_xticklabels()
        self.ticklabels.extend( self.axes.get_yticklabels() )
 

        for line in self.ticklines:
            line.set_linewidth(2)

        for line in self.gridlines:
            line.set_linestyle('-')

        for label in self.ticklabels:
            label.set_fontsize('small')

        self.canvas.show()
        #button_ax = axes([0.7, 0.5, 0.1, 0.75])
        #button = Button(button_ax, 'Press Me')
        #button.on_clicked(self.on_button_clicked)

    def plot(self, x, y):
        self.axes.clear()
        self.axes.plot(x, y)
        self.axes.grid(True)
        self.canvas.destroy()
        self.canvas = FigureCanvasGTK(self.figure)
        self.canvas.show()
        self.widget.pack_start(self.canvas, True, True)

    def semilogy(self, x, y):
        self.axes.clear()
        self.axes.grid(True)
        self.axes.semilogy(x, y)
        self.canvas.destroy()
        self.canvas = FigureCanvasGTK(self.figure)
        self.canvas.show()
        self.widget.pack_start(self.canvas, True, True)

    def autocor(self, x):
        self.axes.clear()
        self.axes.grid(True)
        self.axes.acorr(x)
        self.canvas.destroy()
        self.canvas = FigureCanvasGTK(self.figure)
        self.canvas.show()
        self.widget.pack_start(self.canvas, True, True)


    def power_spectrum(self, x, n, fs):
        self.axes.clear()
        self.axes.grid(True)
        self.axes.psd(x, NFFT = n, Fs = fs)
        self.canvas.destroy()
        self.canvas = FigureCanvasGTK(self.figure)
        self.canvas.show()
        self.widget.pack_start(self.canvas, True, True)
        

    def clear_figure(self):
        self.axes.clear()
        self.canvas.destroy()
        self.axes.grid(True)
        self.canvas = FigureCanvasGTK(self.figure)
        self.canvas.show()
        self.widget.pack_start(self.canvas, True, True)

    def enable_span(self):
        #self.rec = RectangleSelector(self.axes, self.line_select_callback,
        #                            drawtype='box',useblit=True,
        #                            minspanx=5,minspany=5)
        # Unref original sublot
        #xmin, xmax = self.axes.get_xlim()
        #self.lx_min = xmin
        #self.lx_max = xmax
        self.span = SpanSelector(self.axes, self.on_select, 'horizontal', useblit=False,
                                rectprops=dict(alpha=0.5, facecolor='red'))       
        self.span.visible = True
        #self.lx = self.axes.plot((0,0), (0,0), 'k-')
#.........这里部分代码省略.........
开发者ID:aalonso,项目名称:sigbox,代码行数:103,代码来源:graphic.py

示例5: __init__

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class appGui:
    def __init__(self):
        gladefile = "project2.glade"
        self.windowname = "gtkbench"
        self.wTree = gtk.glade.XML(gladefile, self.windowname)
        self.win = self.wTree.get_widget("gtkbench")
        self.win.maximize()
        dic = {"on_window1_destroy" : gtk.main_quit,
            "on_button1_clicked" : self.submitDB,
            "on_button3_clicked" : self.fillTree,
            "on_notebook1_switch_page" : self.selectNotebookPage,
            "on_treeview1_button_press_event" : self.clickTree,
                "on_button2_clicked" : self.createProjectGraph
            }
         
        self.wTree.signal_autoconnect(dic)
        # start with database selection
        self.wDialog = gtk.glade.XML("project2.glade", "dbSelector")
         
        # setup matplotlib stuff on first notebook page (empty graph)
        self.figure = Figure(figsize=(6,4), dpi=72)
        self.axis = self.figure.add_subplot(111)
         
        self.axis.set_xlabel('Yepper')
        self.axis.set_ylabel('Flabber')
        self.axis.set_title('An Empty Graph')
        self.axis.grid(True)
     
        self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea
        self.canvas.show()
        self.graphview = self.wTree.get_widget("vbox1")
        self.graphview.pack_start(self.canvas, True, True)
         
        # setup listview for database
        self.listview = self.wTree.get_widget("treeview1")
        self.listmodel = gtk.ListStore(str, int, int, str, str)
        self.listview.set_model(self.listmodel)
 
        renderer = gtk.CellRendererText()
         
        column = gtk.TreeViewColumn("Name",renderer, text=0)
        column.set_clickable(True)
        column.set_sort_column_id(0)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #renderer = gtk.CellRendererText()
         
        column = gtk.TreeViewColumn("Age",renderer, text=1)
        column.set_clickable(True)
        column.set_sort_column_id(1)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #self.listview.show()
         
        column = gtk.TreeViewColumn("Shoesize",renderer, text=2)
        column.set_clickable(True)
        column.set_sort_column_id(2)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #self.listview.show()
 
        column = gtk.TreeViewColumn("Created",renderer, text=3)
        column.set_clickable(True)
        column.set_sort_column_id(3)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
        #self.listview.show()
        #renderer = gtk.CellRendererText()
 
        column = gtk.TreeViewColumn("Updated",renderer, text=4)
        column.set_clickable(True)
        column.set_sort_column_id(4)
        column.connect("clicked", self.createDBGraph)
        column.set_resizable(True)
        self.listview.append_column(column)
 
 
        return
     
    # callbacks.
    def submitDB(self, widget):
        while True:
            try:
                name = self.wTree.get_widget("entry1").get_text()
                age = self.wTree.get_widget("entry2").get_text()
                size = self.wTree.get_widget("entry3").get_text()
                assert name != ""
                assert age != ""
                assert size != ""
                dataUsr = name, age, size                
                sd = DBStuff.Eb_db(host, user, passwd, db)
                sd.subMit(dataUsr)
                break
            except AssertionError:
                self.wDialog = gtk.glade.XML("project2.glade", "dbWarningEmpty")
                close = self.wDialog.get_widget("dbWarningEmpty")
#.........这里部分代码省略.........
开发者ID:sauravkumar2014,项目名称:ASCEND,代码行数:103,代码来源:pygladematplotlib.py

示例6: __init__

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class appgui:
	def __init__(self):
		self.gladefile = "attenuation_calc.glade"
		windowname = "MainWindow"
		self.wTree=gtk.glade.XML(self.gladefile, windowname)

		dic = { "on_GetDataButton_clicked" : self.button1_clicked,
			"on_SaveImageMenuItem_activate" : self.save_image,
			"on_ExportMenuItem_activate" : self.save_data,
			"on_MainWindow_destroy" : (gtk.main_quit) ,
			"on_QuitMenuItem_activate" : (gtk.main_quit),
			"on_about_menuitem_activate" : self.about }

		self.wTree.signal_autoconnect(dic)

		self.figure = Figure(figsize=(6,4), dpi=72)
		self.axis = self.figure.add_subplot(111)
		self.axis.set_xlabel('Energies')
		self.axis.set_ylabel('Attenuation Length (microns)')
		self.axis.set_title('Attenuation Lengths vs Energy')
		self.axis.grid(True)
		self.canvas = FigureCanvasGTK(self.figure)
		self.canvas.show()
		self.graphview = self.wTree.get_widget("vbox1")
		self.graphview.pack_start(self.canvas,True,True)
		#self.graphview.pack_start(self.canvas,True,True)

		self.wTree.get_widget(windowname).maximize()

		self.E = {}
		self.attlen = {}

		return

	def about(self,widget):
		print 'Hello World'
		
		t = gtk.glade.XML(self.gladefile, "aboutdialog1")
	
		about = t.get_widget("aboutdialog1")

		about.run()
		about.hide()

		return

	def button1_clicked(self,widget):
		self.graphview.remove(self.canvas) # important else they just get inserted again each time (not replaced)
		self.axis.cla()
		eltext = self.wTree.get_widget("ElementText").get_text()
		if eltext.find(',') == -1:
			el = self.wTree.get_widget("ElementText").get_text().split()
		else:
			el = self.wTree.get_widget("ElementText").get_text().split(',')		
		
		[self.E,self.attlen] = nx.calclengths(el)
		for e in self.attlen.keys():
			self.axis.loglog(self.E[e],self.attlen[e],label=e);
		self.axis.set_xlabel('Energy (MeV)')
		self.axis.set_ylabel('Attenuation Length (cm)')
		self.axis.set_title('Attenuation Lengths vs Energy')
		self.axis.legend(loc='lower right')
		self.axis.grid(True)
		self.canvas.destroy()
                self.canvas = FigureCanvasGTK(self.figure)
                self.canvas.show()
		self.graphview = self.wTree.get_widget("vbox1")
                self.graphview.pack_end(self.canvas, True, True)
                #self.graphview.pack_start(self.canvas, True, True)

		#print dir(self.canvas)

	def save_image(self,widget):
		chooser = gtk.FileChooserDialog(title='Save File',action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                  buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))

		chooser.set_default_response(gtk.RESPONSE_OK)

		response = chooser.run()
		if response == gtk.RESPONSE_OK:	
			print chooser.get_filename()
			self.figure.savefig(chooser.get_filename())
		else:
			print 'No files selected'

		chooser.destroy()
	
	def save_data(self,widget):
		chooser = gtk.FileChooserDialog(title='Save File',action=gtk.FILE_CHOOSER_ACTION_SAVE,
                                  buttons=(gtk.STOCK_CANCEL,gtk.RESPONSE_CANCEL,gtk.STOCK_OPEN,gtk.RESPONSE_OK))
	
		chooser.set_default_response(gtk.RESPONSE_OK)

		response = chooser.run()
		if response == gtk.RESPONSE_OK:
			print chooser.get_filename()

			filename = chooser.get_filename()

			Eint = []
#.........这里部分代码省略.........
开发者ID:davepeake,项目名称:XRay_Attenuation,代码行数:103,代码来源:attenuation_calc.py

示例7: Backend

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class Backend( backend.Backend ):

    def init(self):
        # line_cache: key = id(Curve), value=mpl line object
        self.line_cache = dict()
        
        self.layer_to_axes = dict()
        self.axes_to_layer = dict()
        self.layers_cache = list() # copy of self.plot.layers
        
    def connect(self):
        logger.debug("Opening matplotlib session.")        

        self.figure = Figure(dpi=100, facecolor="white")  # figsize=(5,4), dpi=100)        
        self.canvas = FigureCanvas(self.figure)
        self.canvas.show()

        self.line_cache.clear()
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()

        backend.Backend.connect(self)
        logger.debug("Init finished")


    def disconnect(self):
        logger.debug("Closing matplotlib session.")

        if not self.canvas is None:
            self.canvas.destroy()
            self.canvas = None
        if not self.figure is None:
            self.figure = None
        
        backend.Backend.disconnect(self)


    #----------------------------------------------------------------------

    def arrange(self, rows=1, cols=1):

        layers = self.plot.layers
        n = len(layers)

        if n > (rows*cols):
            rows = int((rows*cols) / n) + 1
            cols = rows * n
            #raise ValueError("Not enough rows and cols for all layers!")

        self.figure.clear()
        self.figure.axes = []
        
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()
        self.layers_cache = list()
        j = 1
        for layer in layers:
            print "Setting up layer", layer
            axes = self.figure.add_subplot("%d%d%d" % (rows,cols,j))
            self.layer_to_axes[layer] = axes
            self.axes_to_layer[axes] = layer
            self.layers_cache.append(layer)
            j += 1
        

        
    def draw_layer(self, layer, group_info):

        ax = self.layer_to_axes[layer]

        print "DRAWING AXES ", ax
        ax.lines = []

        line_cache = []
        line_count = 0
        last_cx = -1

        # Default values come in two flavors:
        # group-wise and single default values        
        group_colors = uwrap.get(layer, 'group_colors')
        group_styles = uwrap.get(layer, 'group_styles')
        group_markers = uwrap.get(layer, 'group_markers')

        #default_color = 'r'
        default_color = None
        default_style = 'solid'
        default_marker = 'None'
        

        #:layer.visible
        if uwrap.get(layer, 'visible') is False:
            return

        #:layer.title
        title = uwrap.get(layer, 'title', None)
        if title is not None:
            ax.set_title(title)        

        #:layer.grid
        grid = uwrap.get(layer, 'grid')
#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sloppyplot-svn,代码行数:103,代码来源:mpl.py

示例8: Backend

# 需要导入模块: from matplotlib.backends.backend_gtk import FigureCanvasGTK [as 别名]
# 或者: from matplotlib.backends.backend_gtk.FigureCanvasGTK import destroy [as 别名]
class Backend( backend.Backend ):

    def init(self):
        
        self.layer_to_axes = {}
        self.axes_to_layer = {}
        self.layers_cache = [] # copy of self.plot.layers
        self.layer_signals = {}
        
        self.line_caches = {}
        self.omaps = {}
        
        
    def connect(self):
        logger.debug("Opening matplotlib session.")        

        self.figure = Figure(dpi=100, facecolor="white")  # figsize=(5,4), dpi=100)        
        self.canvas = FigureCanvas(self.figure)
        self.canvas.show()

        self.line_caches = {}
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()

        backend.Backend.connect(self)
        logger.debug("Init finished")


    def set(self, project,plot):
        backend.Backend.set(self, project, plot)
        if self.project is not None:
            # TODO: connect to notify::layers of Plot
            pass

    def disconnect(self):
        logger.debug("Closing matplotlib session.")

        if not self.canvas is None:
            self.canvas.destroy()
            self.canvas = None
        if not self.figure is None:
            self.figure = None
        
        backend.Backend.disconnect(self)


        

    #----------------------------------------------------------------------

    def arrange(self, rows=1, cols=1):

        layers = self.plot.layers
        n = len(layers)

        if n > (rows*cols):
            rows = int((rows*cols) / n) + 1
            cols = rows * n
            #raise ValueError("Not enough rows and cols for all layers!")

        self.figure.clear()
        self.figure.axes = []
        
        self.layer_to_axes.clear()
        self.axes_to_layer.clear()
        self.layers_cache = []

        for signal_list in self.layer_signals.itervalues():
            for signal in signal_list:
                Signals.disconnect(signal)
        self.layer_signals = {}
        
        j = 1
        for layer in layers:
            print "Setting up layer", layer
            axes = self.figure.add_subplot("%d%d%d" % (rows,cols,j))
            self.layer_to_axes[layer] = axes
            self.axes_to_layer[axes] = layer
            self.layers_cache.append(layer)

            print "Connecting to notify of ", layer
            self.layer_signals[layer] = \
              [Signals.connect(layer, 'notify', self.on_update_sobject),
               Signals.connect(layer, 'notify::labels', self.on_update_labels)]

            j += 1

        
    def draw_layer(self, layer, group_info):

        ax = self.layer_to_axes[layer]
        logger.info ("drawing layer %s (axes %s)" % (layer, ax))

        omap = self.omaps[layer]
        
        ax.lines = []

        line_cache = self.line_caches[layer] = []
        last_cx = -1

#.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:sloppyplot-svn,代码行数:103,代码来源:mpl.py


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