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


Python pylab.ioff函数代码示例

本文整理汇总了Python中matplotlib.pylab.ioff函数的典型用法代码示例。如果您正苦于以下问题:Python ioff函数的具体用法?Python ioff怎么用?Python ioff使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: print_plot

	def print_plot(self, title):
		'''
		Outputs the current grid to a .png file
		'''
		plt.ioff()
		fig, axs = plt.subplots()

		#Default extrema values for x & y dimension
		max_x, min_x = 1, -1
		max_y, min_y = 1, -1

		for brick in self.plane.grid:
			#Draw the brick
			axs.add_patch(Rectangle((brick[0].x, brick[0].y), brick[0].n, brick[0].h))

			#Find extrema
			for pos in brick[0].pos:
				max_x = max([max_x, pos[0]])
				min_x = min([min_x, pos[0]])
				max_y = max([max_y, pos[1]])
				min_y = min([min_y, pos[1]])
		if len(self.plane.grid) > 1:
			plt.title('Chromosome - f=%.3f' %self.eval_func())
		else:
			plt.title('Chromosome - f=000')

		#Create buffer around edge of drawing in the graph
		axs.set_xlim(min_x - 2.5, max_x + 5.0)
		axs.set_ylim(min_y - 2.5, max_y + 5.0)

		fig.savefig(str(title) + '.png')
		plt.close(fig)
开发者ID:MaxOSmith,项目名称:Lego_Structural_Design,代码行数:32,代码来源:LedgeProblem.py

示例2: __init__

    def __init__(self, folder, **kwargs):  
        
        if not os.path.isdir(os.path.join(folder, 'plots')):
            os.mkdir(os.path.join(folder, 'plots'))
        plt.ioff()
        self.metrics_fig = plt.figure('Metrics')
        self.ax2 = self.metrics_fig.add_subplot(111)

        self.p1, = self.ax2.plot([], [], 'ro-', label='TEST: Pixel accuracy')
        self.p5, = self.ax2.plot([], [], 'rv-', label='TRAIN: Pixel accuracy')
        
        self.p2, = self.ax2.plot([], [], 'bo-', label='TEST: Mean-Per-Class accuracy')
        self.p6, = self.ax2.plot([], [], 'bv-', label='TRAIN:Mean-Per-Class accuracy')
        
        self.p3, = self.ax2.plot([], [], 'go-', label='TEST: Mean-Per-Class IU')
        self.p7, = self.ax2.plot([], [], 'gv-', label='TRAIN:Mean-Per-Class IU')
        
        self.p4, = self.ax2.plot([], [], 'ko-', label='TEST: Freq. weigh. mean IU')
        self.p8, = self.ax2.plot([], [], 'kv-', label='TRAIN:Freq. weigh. mean IU')
        


        plt.xlabel('iterations')
        self.handles2, self.labels2 = self.ax2.get_legend_handles_labels()
        self.lgd2 = self.ax2.legend(self.handles2, self.labels2, loc='upper center', bbox_to_anchor=(0.5,-0.2))
        self.ax2.grid(True)    
        plt.draw()
开发者ID:mtreml,项目名称:utils,代码行数:27,代码来源:montrain.py

示例3: matrix_plot

    def matrix_plot(self, matrix, figure_name='matrix_plot.pdf'):
        import numpy
        from matplotlib import pylab
        def _blob(x,y,area,colour):
            hs = numpy.sqrt(area) / 2
            xcorners = numpy.array([x - hs, x + hs, x + hs, x - hs])
            ycorners = numpy.array([y - hs, y - hs, y + hs, y + hs])
            pylab.fill(xcorners, ycorners, colour, edgecolor=colour)
        reenable = False
        if pylab.isinteractive():
            pylab.ioff()
        pylab.clf()
        
        maxWeight = 2**numpy.ceil(numpy.log(numpy.max(numpy.abs(matrix)))/numpy.log(2))
        height, width = matrix.shape
        pylab.fill(numpy.array([0,width,width,0]),numpy.array([0,0,height,height]),'white')
        pylab.axis('off')
        pylab.axis('equal')
        for x in xrange(width):
            for y in xrange(height):
                _x = x+1
                _y = y+1
                w = matrix[y,x]
                if w > 0:
                    _blob(_x - 0.5, height - _y + 0.5, 0.2,'#0099CC')
                elif w < 0:
                    _blob(_x - 0.5, height - _y + 0.5, 0.2,'#660000')

        if reenable:
            pylab.ion()
        pylab.savefig(figure_name) 
开发者ID:1zinnur9,项目名称:pymaclab,代码行数:31,代码来源:steady_flux_analyzer.py

示例4: plot_average

def plot_average(filenames, save_plot=True, show_plot=False, dpi=100):

    ''' Plot Signal average from a list of averaged files. '''

    fname = get_files_from_list(filenames)

    # plot averages
    pl.ioff()  # switch off (interactive) plot visualisation
    factor = 1e15
    for fnavg in fname:
        name = fnavg[0:len(fnavg) - 4]
        basename = os.path.splitext(os.path.basename(name))[0]
        print fnavg
        # mne.read_evokeds provides a list or a single evoked based on condition.
        # here we assume only one evoked is returned (requires further handling)
        avg = mne.read_evokeds(fnavg)[0]
        ymin, ymax = avg.data.min(), avg.data.max()
        ymin *= factor * 1.1
        ymax *= factor * 1.1
        fig = pl.figure(basename, figsize=(10, 8), dpi=100)
        pl.clf()
        pl.ylim([ymin, ymax])
        pl.xlim([avg.times.min(), avg.times.max()])
        pl.plot(avg.times, avg.data.T * factor, color='black')
        pl.title(basename)

        # save figure
        fnfig = os.path.splitext(fnavg)[0] + '.png'
        pl.savefig(fnfig, dpi=dpi)

    pl.ion()  # switch on (interactive) plot visualisation
开发者ID:dongqunxi,项目名称:jumeg,代码行数:31,代码来源:jumeg_plot.py

示例5: plot

def plot(y, function):
    """ Show an animation of Poincare plot.

    --- arguments ---
    y: A list of initial values
    function: function which is argument of Runge-Kutta solver
    """
    h = dt
    fig = plt.figure()
    ax = fig.add_subplot(111)
    ax.grid()
    time_text = ax.text(0.05, 0.9, '', transform=ax.transAxes)
    plt.ion()

    for i in range(nmax + 1):
        for j in range(nstep):
            rk4 = RK.RK4(function)
            y = rk4.solve(y, j * h, h)
            # -pi <= theta <= pi
            while y[0] > pi:
                y[0] = y[0] - 2 * pi
            while y[0] < -pi:
                y[0] = y[0] + 2 * pi

        if ntransient <= i < nmax:          # <-- draw the poincare plots
            plt.scatter(y[0], y[1], s=2.0, marker='o', color='blue')
            time_text.set_text('n = %d' % i)
            plt.draw()

        if i == nmax:                       # <-- to stop the interactive mode
            plt.ioff()
            plt.scatter(y[0], y[1], s=2.0, marker='o', color='blue')
            time_text.set_text('n = %d' % i)
            plt.show()
开发者ID:ssh0,项目名称:6-14_poincare,代码行数:34,代码来源:6-14_poincare_a.py

示例6: __call__

   def __call__(self, **params):

       p = ParamOverrides(self, params)
       fig = plt.figure(figsize=(5, 5))

       # This one-liner works in Octave, but in matplotlib it
       # results in lines that are all connected across rows and columns,
       # so here we plot each line separately:
       #   plt.plot(x,y,"k-",transpose(x),transpose(y),"k-")
       # Here, the "k-" means plot in black using solid lines;
       # see matplotlib for more info.
       isint = plt.isinteractive() # Temporarily make non-interactive for
       # plotting
       plt.ioff()
       for r, c in zip(p.y[::p.skip], p.x[::p.skip]):
           plt.plot(c, r, "k-")
       for r, c in zip(np.transpose(p.y)[::p.skip],np.transpose(p.x)[::p.skip]):
           plt.plot(c, r, "k-")

       # Force last line avoid leaving cells open
       if p.skip != 1:
           plt.plot(p.x[-1], p.y[-1], "k-")
           plt.plot(np.transpose(p.x)[-1], np.transpose(p.y)[-1], "k-")

       plt.xlabel('x')
       plt.ylabel('y')
       # Currently sets the input range arbitrarily; should presumably figure out
       # what the actual possible range is for this simulation (which would presumably
       # be the maximum size of any GeneratorSheet?).
       plt.axis(p.axis)

       if isint: plt.ion()
       self._generate_figure(p)
       return fig
开发者ID:sarahcattan,项目名称:topographica,代码行数:34,代码来源:pylabplot.py

示例7: test1

    def test1():
        x = [0.5]*3
        xbounds = [(-5, 5) for y in x]


        GA = GenAlg(fitcalc1, x, xbounds, popMult=100, bitsPerGene=9, mutation=(1./9.), crossover=0.65, crossN=2, direction='min', maxGens=60, hammingDist=False)
        results = GA.run()
        print "*** DONE ***"
        #print results
        plt.ioff()
        #generate pareto frontier numerically
        x1_ = np.arange(-5., 0., 0.05)
        x2_ = np.arange(-5., 0., 0.05)
        x3_ = np.arange(-5., 0., 0.05)

        pfn = []
        for x1 in x1_:
            for x2 in x2_:
                for x3 in x3_:
                    pfn.append(fitcalc1([x1,x2,x3]))

        pfn.sort(key=lambda x:x[0])
        
        plt.figure()
        i = 0
        for x in results:
            plt.scatter(x[1][0], x[1][1], 20, c='r')

        plt.scatter([x[0] for x in pfn], [x[1] for x in pfn], 1.0, c='b', alpha=0.1)
        plt.xlim([-20,-1])
        plt.ylim([-12, 2])
        plt.draw()
开发者ID:pattersoniv,项目名称:FFAS,代码行数:32,代码来源:NGSA.py

示例8: kmr_test_plot

def kmr_test_plot(data, k, end_thresh):
    from matplotlib.pylab import ion, figure, draw, ioff, show, plot, cla
    ion()
    fig = figure()
    ax = fig.add_subplot(111)
    ax.grid(True)

    # get k centroids
    kmr = kmeans.kmeans_runner(k, end_thresh)
    kmr.init_data(data)
    print kmr.centroids

    plot(data[:,0], data[:,1], 'o')

    i = 0
    while kmr.stop_flag is False:
        kmr.iterate()
        #print kmr.centroids, kmr.itr_count
        plot(kmr.centroids[:, 0], kmr.centroids[:, 1], 'sr')
        time.sleep(.2)
        draw()
        i += 1

    print "N Iterations: %d" % (i)
    plot(kmr.centroids[:, 0], kmr.centroids[:, 1], 'g^', linewidth=3)

    ioff()
    show()
    print kmr.itr_count, kmr.centroids
开发者ID:cjacoby,项目名称:mir-noise,代码行数:29,代码来源:kmeans_test.py

示例9: CalculateG

def CalculateG(distances):
    
    #distances = distances[:len(distances)/2]

    x = []
    y = []

    for key, value in distances.items():
        x.append(value[0])
        y.append(value[1])
    
    #print(str(x))
    #print(str(y))
    
    fig = plt.figure()
    ax = fig.add_subplot(111)

    p = ax.plot(x, y, 'b')
    ax.set_xlabel('t')
    ax.set_ylabel('s')
    ax.set_title('Simple XY point plot')

    pylab.ioff()
    plt.show()

    def s(t, a):
        return 0.5 * a * t**2
    
    params = curve_fit(s, x, y)
    
    #print(str(params[0]))

    return params[0][0]
开发者ID:Reignbeaux,项目名称:CalculateG,代码行数:33,代码来源:calculate_g.py

示例10: report

def report(): 
    from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
    assert_data()
    df = session['df']
    
    # For example, user could sumbit 2013-10:2014-02 but we need to make this
    #   into '2013-10':'2014-10'
    if 'idx' in session.keys() and len(session['idx'])>0:
        session['_filter']
        idx = session['idx']
        if idx.find(':') > -1:
            lidx, ridx = idx.split(':')
            df = df[lidx:ridx]
        else:
            df = df[idx]
            
    
    startDate = session['startDate']
    endDate = session['endDate']
    if startDate != '' and endDate != '':
        # Filter the data frame to only be a subset of full time range
        startDate = pandas.Timestamp(startDate)
        endDate = pandas.Timestamp(endDate)
        df = df[startDate:endDate]
        
    
    figures = []
    if 'tags' in session.keys() and len(session['tags'])>0:
        figures += GBA.density_cloud_by_tags(df, session['tags'], 
                                            silent=True)
                                            
    if 'pnodes' in session.keys() and len(session['pnodes'])>0:
        import matplotlib.pylab as plt
        plt.ioff()
        
        pnodes = session['pnodes']
        df = GBA.price_at_pnodes(df, pnodes)
        cols = ['COST',] + ['pnode_'+p for p in pnodes]
        figures.append(df[cols].plot().figure)        
        figures.append(df[cols].cumsum().plot().figure)
        
    session.drop('tags')
    s = '<h1>Figures</h1>'
    figures_rendered = []
    for n, fig in enumerate(figures):
        s+='<img src="plt/%d.png" /><br />' % n
        canvas=FigureCanvas(fig)
        png_output = StringIO()
        canvas.print_png(png_output)
        figures_rendered.append(png_output.getvalue())
    session['figures'] = figures_rendered
    s += '<p><a href="/dashboard">Back to dashboard</a></p><br /><br />'
    return s
开发者ID:kevlaria,项目名称:GreenButtonActuator,代码行数:53,代码来源:web.py

示例11: plot_model

def plot_model(galaxy, sect = [x1, x2, y1, y2], directory = '/Volumes/VINCE/dwarfs/combined_VCC/figures/'):
    '''
    A wrapper to plot galfit results, bad pixel mask and other info
    
    INPUT
    'galaxy': Single row of the dataframe produced by the procedure the for loop
              below
    'sect'  : Image sector produced by sector(header). It is the same for all 
              galaxies. Do not need to call sector(header) every time.
    'directory': Where to save the results. Directory needs to be created
    '''
    plt.ioff()
    fig, axarr = plt.subplots(2,3)
    #fig.suptitle('{}'.format(f))

    hdu = fits.open(galaxy['MODEL'])
    image = ndimage.gaussian_filter(hdu[1].data, 1)
    axarr[0, 0].imshow(image, cmap='gray', norm=LogNorm(), vmin=1, vmax = 50)
    axarr[0, 0].set_title('Image')

    model = hdu[2].data
    axarr[0, 1].imshow(model, cmap='Blues', norm=LogNorm(), vmin=0.01, vmax = 6)
    axarr[0, 1].set_title('Model')

    residuals = ndimage.gaussian_filter(hdu[3].data, 1)
    axarr[1, 0].imshow(residuals, cmap='gray', norm=LogNorm(), vmin=1, vmax = 50)
    axarr[1, 0].set_title('Residuals')

    x1, x2, y1, y2 = sect[0], sect[1], sect[2], sect[3]
    themask = themask = getdata(galaxy['MASK'])[x1:x2,y1:y2]
    axarr[1, 1].imshow(themask, cmap='gray', vmin=0, vmax = 1)
    axarr[1, 1].set_title('Mask')
    
    axarr[0, 2].text(0.2, 1.0,r'Galaxy: VCC{}'.format(galaxy['ID']), va="center", ha="left")
    axarr[0, 2].text(0.2, 0.9,r'mtot $=$ {}'.format(galaxy['mtot']), va="center", ha="left")
    axarr[0, 2].text(0.2, 0.8,r'Re $=$ {} pc'.format(galaxy['Re']), va="center", ha="left")
    axarr[0, 2].text(0.2, 0.7,r'n $=$ {}'.format(galaxy['n']), va="center", ha="left")
    axarr[0, 2].text(0.2, 0.6,r'PA $=$ {}'.format(galaxy['PA']), va="center", ha="left")
    axarr[0, 2].text(0.2, 0.5,r'chi2nu $=$ {}'.format(galaxy['chi2nu']), va="center", ha="left")
    
    axarr[0, 2].set_aspect('equal')
    axarr[0, 2].axis('off')

    axarr[1, 2].set_aspect('equal')
    axarr[1, 2].axis('off')

    fig.subplots_adjust(hspace=0., wspace = 0.)
    plt.setp([a.get_xticklabels() for a in axarr.flatten()], visible=False);
    plt.setp([a.get_yticklabels() for a in axarr.flatten()], visible=False);

    fig.savefig(directory + '{}.png'.format(f.split('/')[-1]), dpi= 200)
    plt.close(fig)
开发者ID:vincepota,项目名称:model2D,代码行数:52,代码来源:analyze.py

示例12: __init__

 def __init__(self,stats):
     
     statsA = stats.expOne        
     uni = stats.titOne
     rc('xtick', labelsize=12) 
     rc('ytick', labelsize=12) 
     fig1 = pylab.figure(figsize=(8,5), dpi=100)   
     self.plotCurve(fig1,statsA,len(statsA[0]),"Coverage" ,1)     
     pylab.ioff()
     #to use if needed
     #mytime = '%.2f' % time()
     mytime = ""
     fig1.savefig(os.environ['TEX']+uni+mytime+'.pdf')        
     # display plot if required
     pylab.show()         
开发者ID:camilothorne,项目名称:nasslli2016,代码行数:15,代码来源:simplots.py

示例13: plot

    def plot(self, func, interp=True, plotter='imshow'):
        import matplotlib as mpl
        from matplotlib import pylab as pl
        if interp:
            lpi = self.interpolator(func)
            z = lpi[self.yrange[0]:self.yrange[1]:complex(0, self.nrange),
                    self.xrange[0]:self.xrange[1]:complex(0, self.nrange)]
        else:
            y, x = np.mgrid[
                self.yrange[0]:self.yrange[1]:complex(0, self.nrange),
                self.xrange[0]:self.xrange[1]:complex(0, self.nrange)]
            z = func(x, y)

        z = np.where(np.isinf(z), 0.0, z)

        extent = (self.xrange[0], self.xrange[1],
            self.yrange[0], self.yrange[1])
        pl.ioff()
        pl.clf()
        pl.hot()  # Some like it hot
        if plotter == 'imshow':
            pl.imshow(np.nan_to_num(z), interpolation='nearest', extent=extent,
                      origin='lower')
        elif plotter == 'contour':
            Y, X = np.ogrid[
                self.yrange[0]:self.yrange[1]:complex(0, self.nrange),
                self.xrange[0]:self.xrange[1]:complex(0, self.nrange)]
            pl.contour(np.ravel(X), np.ravel(Y), z, 20)
        x = self.x
        y = self.y
        lc = mpl.collections.LineCollection(
            np.array([((x[i], y[i]), (x[j], y[j]))
                      for i, j in self.tri.edge_db]),
            colors=[(0, 0, 0, 0.2)])
        ax = pl.gca()
        ax.add_collection(lc)

        if interp:
            title = '%s Interpolant' % self.name
        else:
            title = 'Reference'
        if hasattr(func, 'title'):
            pl.title('%s: %s' % (func.title, title))
        else:
            pl.title(title)

        pl.show()
        pl.ion()
开发者ID:AdamHeck,项目名称:matplotlib,代码行数:48,代码来源:testfuncs.py

示例14: get_rp_as_imagebuf

def get_rp_as_imagebuf(features, width=493, height=352, dpi=72, cmap="jet"):

    features = features.reshape(24, 60, order="F")

    plt.ioff()
    fig = plt.figure(figsize=(int(width / dpi), int(height / dpi)), dpi=dpi)
    ax = fig.add_subplot(111)
    fig.suptitle("Rhythm Patterns")
    ax.imshow(features, origin="lower", aspect="auto", interpolation="nearest", cmap=cmap)
    ax.set_xlabel("Mod. Frequency Index")
    ax.set_ylabel("Frequency [Bark]")

    img_buffer = io.BytesIO()
    plt.savefig(img_buffer, format="png")
    img_buffer.seek(0)
    plt.close()
    plt.ion()
    return base64.b64encode(img_buffer.getvalue())
开发者ID:EQ4,项目名称:mir_utils,代码行数:18,代码来源:NotebookUtils.py

示例15: plot

def plot(magfile):

    rapert,flux = readaper(magfile)
    
    plt.ioff() #turn off interactive so plots dont pop up 
    plt.figure(figsize=(8,10)) #this is in inches
    
    
    plt.xlabel('radius')
    plt.ylabel('total flux')
    plt.plot(rapert,flux,'bx')
    plt.title(magfile,{'fontsize':10})

    plt.title("Total flux collected per aperture")
        
    outfile=magfile+".pdf"
    plt.savefig(outfile)
    print(("saved output figure to %s")%(outfile))
开发者ID:Tuo-Ji,项目名称:scientific-python-training-2015,代码行数:18,代码来源:apercor.py


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