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


Python pylab.text函数代码示例

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


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

示例1: plot_cfl_results

def plot_cfl_results(results):

    cfl = np.array([r.CFL_NUMBER for r in results.ANALYSES.values()])
    its = np.array([r.ITERATIONS for r in results.ANALYSES.values()])
    evl = np.arange(len(cfl))

    i = np.argsort(cfl)
    cfl = cfl[i]
    its = its[i]
    evl = evl[i]

    its[its > 1000] = np.nan

    plt.figure(1)
    plt.clf()

    plt.plot(cfl, its, "bo-", lw=2, ms=10)
    plt.xlabel("CFL Number")
    plt.ylabel("Iterations")
    for e, x, y in zip(evl, cfl, its):
        plt.text(x, y, "%i" % (e + 1))

    plt.savefig("cfl_history.eps")

    plt.close()
开发者ID:juantresde,项目名称:SU2,代码行数:25,代码来源:find_cfl_number.py

示例2: plotB3reg

def plotB3reg():
    w=loadStanFit('revE2B3BHreg.fit')
    printCI(w,'mmu')
    printCI(w,'mr')
    for b in range(2):
        subplot(1,2,b+1)
        plt.title('')
        px=np.array(np.linspace(-0.5,0.5,101),ndmin=2)
        a0=np.array(w['mmu'][:,b],ndmin=2).T
        a1=np.array(w['mr'][:,b],ndmin=2).T
        y=np.concatenate([sap(a0+a1*px,97.5,axis=0),sap(a0+a1*px[:,::-1],2.5,axis=0)])
        x=np.squeeze(np.concatenate([px,px[:,::-1]],axis=1))
        plt.plot(px[0,:],np.median(a0)+np.median(a1)*px[0,:],'red')
        #plt.plot([-1,1],[0.5,0.5],'grey')
        ax=plt.gca()
        ax.set_aspect(1)
        ax.add_patch(plt.Polygon(np.array([x,y]).T,alpha=0.2,fill=True,fc='red',ec='w'))
        y=np.concatenate([sap(a0+a1*px,75,axis=0),sap(a0+a1*px[:,::-1],25,axis=0)])
        ax.add_patch(plt.Polygon(np.array([x,y]).T,alpha=0.2,fill=True,fc='red',ec='w'))
        man=np.array([-0.4,-0.2,0,0.2,0.4])
        mus=[]
        for m in range(len(man)):
            mus.append(loadStanFit('revE2B3BH%d.fit'%m)['mmu'][:,b])
        mus=np.array(mus).T
        errorbar(mus,x=man)
        ax.set_xticks(man)
        plt.xlim([-0.5,0.5])
        plt.ylim([-0.4,0.8])
        #plt.xlabel('Manipulated Displacement')
        if b==0:
            plt.ylabel('Perceived Displacemet')
            plt.gca().set_yticklabels([])
        subplot_annotate()
    plt.text(-1.1,-0.6,'Pivot Displacement',fontsize=8);
开发者ID:simkovic,项目名称:wolfpackRevisited,代码行数:34,代码来源:Evaluation.py

示例3: cmap_plot

def cmap_plot(cmdLine):

    pylab.figure(figsize=[5,10])
    a=outer(ones(10),arange(0,1,0.01))
    subplots_adjust(top=0.99,bottom=0.00,left=0.01,right=0.8)
    maps=[m for m in cm.datad if not m.endswith("_r")]
    maps.sort()
    l=len(maps)+1
    for i, m in enumerate(maps):
        print m
        subplot(l,1,i+1)
        pylab.setp(pylab.gca(),xticklabels=[],xticks=[],yticklabels=[],yticks=[])
        imshow(a,aspect='auto',cmap=get_cmap(m),origin="lower")
        pylab.text(100.85,0.5,m,fontsize=10)

# render plot

    if cmdLine: 
        pylab.show(block=True)
    else: 
        pylab.ion()
        pylab.plot([])
        pylab.ioff()
	
    status = 1
    return status
开发者ID:KeplerGO,项目名称:PyKE,代码行数:26,代码来源:kepprf.py

示例4: plot_prob_effector

def plot_prob_effector(sens, fpr, xmax=1, baserate=0.1):
    """Plots a line graph of P(effector|positive test) against
    the baserate of effectors in the input set to the classifier.
        
    The baserate argument draws an annotation arrow
    indicating P(pos|+ve) at that baserate
    """
    assert 0.1 <= xmax <= 1, "Max x axis value must be in range [0,1]"
    assert 0.01 <= baserate <= 1, "Baserate annotation must be in range [0,1]"
    baserates = pylab.arange(0, 1.05, xmax * 0.005)  
    probs = [p_correct_given_pos(sens, fpr, b) for b in baserates]
    pylab.plot(baserates, probs, 'r')
    pylab.title("P(eff|pos) vs baserate; sens: %.2f, fpr: %.2f" % (sens, fpr))
    pylab.ylabel("P(effector|positive)")
    pylab.xlabel("effector baserate")
    pylab.xlim(0, xmax)
    pylab.ylim(0, 1)
    # Add annotation arrow
    xpos, ypos = (baserate, p_correct_given_pos(sens, fpr, baserate))
    if baserate < xmax:
        if xpos > 0.7 * xmax:
            xtextpos = 0.05 * xmax
        else:
            xtextpos = xpos + (xmax-xpos)/5.
        if ypos > 0.5:
            ytextpos = ypos - 0.05
        else:
            ytextpos = ypos + 0.05
        pylab.annotate('baserate: %.2f, P(pos|+ve): %.3f' % (xpos, ypos), 
                       xy=(xpos, ypos), 
                       xytext=(xtextpos, ytextpos),
                       arrowprops=dict(facecolor='black', shrink=0.05))
    else:
        pylab.text(0.05 * xmax, 0.95, 'baserate: %.2f, P(pos|+ve): %.3f' % \
                   (xpos, ypos))
开发者ID:widdowquinn,项目名称:Teaching-EMBL-Plant-Path-Genomics,代码行数:35,代码来源:ex03.py

示例5: _draw_V

    def _draw_V(self):
        """ draw the V-cycle on our optional visualization """
        xdown = numpy.linspace(0.0, 0.5, self.nlevels)
        xup = numpy.linspace(0.5, 1.0, self.nlevels)

        ydown = numpy.linspace(1.0, 0.0, self.nlevels)
        yup = numpy.linspace(0.0, 1.0, self.nlevels)

        pylab.plot(xdown, ydown, lw=2, color="k")
        pylab.plot(xup, yup, lw=2, color="k")

        pylab.scatter(xdown, ydown, marker="o", color="k", s=40)
        pylab.scatter(xup, yup, marker="o", color="k", s=40)

        if self.up_or_down == "down":
            pylab.scatter(
                xdown[self.nlevels - self.current_level - 1],
                ydown[self.nlevels - self.current_level - 1],
                marker="o",
                color="r",
                zorder=100,
                s=38,
            )

        else:
            pylab.scatter(xup[self.current_level], yup[self.current_level], marker="o", color="r", zorder=100, s=38)

        pylab.text(0.7, 0.1, "V-cycle %d" % (self.current_cycle))
        pylab.axis("off")
开发者ID:jzuhone,项目名称:pyro2,代码行数:29,代码来源:multigrid.py

示例6: plot_genome

def plot_genome(out_file, data_file, samples, dpi=300, screen=False):
    if screen: PL.rcParams.update(PLOT_PARAMS_SCREEN)
    LOG.info("plot_genome - out_file=%s, data_file=%s, samples=%s, dpi=%d"%(out_file, data_file, str(samples), dpi))
    colors = 'bgryckbgryck'

    data = read_posterior(data_file)
    if samples is None or len(samples) == 0: samples = data.keys()
    if len(samples) == 0: return

    PL.figure(None, [14, 4])
    right_end = 0 # rightmost plotted base pair
    for chrm in sort_chrms(data.values()[0]): # for chromosomes in ascending order
        max_site = max(data[samples[0]][chrm]['L']) # length of chromosome
        for s, sample in enumerate(samples): # plot all samples
            I = SP.where(SP.array(data[sample][chrm]['SD']) < 0.3)[0] # at sites that have confident posteriors
            PL.plot(SP.array(data[sample][chrm]['L'])[I] + right_end, SP.array(data[sample][chrm]['AF'])[I], alpha=0.4, color=colors[s], lw=2) # offset by the end of last chromosome
        if right_end > 0: PL.plot([right_end, right_end], [0,1], 'k--', lw=0.4, alpha=0.2) # plot separators between chromosomes
        new_right = right_end + max(data[sample][chrm]['L'])
        PL.text(right_end + 0.5*(new_right - right_end), 0.9, str(chrm), horizontalalignment='center')
        right_end = new_right # update rightmost end
    PL.plot([0,right_end], [0.5,0.5], 'k--', alpha=0.3)
    PL.xlim(0,right_end)
    xrange = SP.arange(0,right_end, 1000000)
    PL.xticks(xrange, ["%d"%(int(x/1000000)) for x in xrange])
    PL.xlabel("Genome (Mb)"), PL.ylabel("Reference allele frequency")
    PL.savefig(out_file, dpi=dpi)
开发者ID:PMBio,项目名称:sqtl,代码行数:26,代码来源:genome.py

示例7: plot_frontier

	def plot_frontier(self,frontier_only=False,plot_samples=True) :
		""" Plot the frontier"""
		frontier = self.frontier
		frontier_energy = self.frontier_energy
		feat1,feat2 = self.feats	
	
		pl.figure()
		if not frontier_only :	
			ll_list1,ll_list2 = zip(*self.all_seq_energy)
			pl.plot(ll_list1,ll_list2,'b*')
		if plot_samples :
			ll_list1,ll_list2 = zip(*self.sample_seq_energy)
			pl.plot(ll_list1,ll_list2,'g*')
					
		pl.plot(*zip(*sorted(frontier_energy)),color='magenta',\
			marker='*',	linestyle='dashed')
		ctr = dict(zip(set(frontier_energy),[0]*
			len(set(frontier_energy))))
		for i,e in enumerate(frontier_energy) : 
			ctr[e] += 1
			pl.text(e[0],e[1]+0.1*ctr[e],str(i),fontsize=10)
			pl.text(e[0]+0.4,e[1]+0.1*ctr[e],frontier[i],fontsize=9)	
		pl.xlabel('Energy:'+feat1)
		pl.ylabel('Energy:'+feat2)
		pl.title('Energy Plot')
		xmin,xmax = pl.xlim()
		ymin,ymax = pl.ylim()
		pl.xlim(xmin,xmax)
		pl.ylim(ymin,ymax)
		pic_dir = '../docs/tex/pics/'
		pl.savefig(pic_dir+self.name+'.pdf')
		pl.savefig(pic_dir+self.name+'.png')
开发者ID:smoitra87,项目名称:pareto-hmm,代码行数:32,代码来源:exp1.py

示例8: print_matplotlib

def print_matplotlib(s):
    pylab.figure()
    pylab.text(0,0,s)
    pylab.axis('off')
    pylab.figure()
    #pylab.show()
    return 
开发者ID:tsarvey,项目名称:spinwaves,代码行数:7,代码来源:spinwave_calc_file_changed.py

示例9: _show_rates

def _show_rates(rate, wo, wt, attenuator, tau_NP, tau_P):
    import pylab

    #pylab.figure()
    pylab.errorbar(rate, wt[0], yerr=wt[1], fmt='g.', label='attenuated')
    pylab.errorbar(rate, wo[0], yerr=wo[1], fmt='b.', label='unattenuated')

    pylab.xscale('log')
    pylab.yscale('log')
    pylab.xlabel('incident rate (counts/second)')
    pylab.ylabel('observed rate (counts/second)')
    pylab.legend(loc='best')
    pylab.grid(True)
    pylab.plot(rate, rate/attenuator, 'g-', label='target')
    pylab.plot(rate, rate, 'b-', label='target')

    Ipeak, Rpeak = peak_rate(tau_NP=tau_NP, tau_P=tau_P)
    if rate[0] <= Ipeak <= rate[-1]:
        pylab.axvline(x=Ipeak, ls='--', c='b')
        pylab.text(x=Ipeak, y=0.05, s=' %g'%Ipeak,
                   ha='left', va='bottom',
                   transform=pylab.gca().get_xaxis_transform())
    if False:
        pylab.axhline(y=Rpeak, ls='--', c='b')
        pylab.text(y=Rpeak, x=0.05, s=' %g\n'%Rpeak,
                   ha='left', va='bottom',
                   transform=pylab.gca().get_yaxis_transform())
开发者ID:reflectometry,项目名称:reduction,代码行数:27,代码来源:deadtime_fit.py

示例10: scatter_stats

def scatter_stats(db, s1, s2, f1=None, f2=None, **kwargs):
    if f1 == None:
        f1 = lambda x: x  # constant function

    if f2 == None:
        f2 = f1

    x = []
    xerr = []

    y = []
    yerr = []

    for k in db:
        x_k = [f1(x_ki) for x_ki in db[k].__getattribute__(s1).gettrace()]
        y_k = [f2(y_ki) for y_ki in db[k].__getattribute__(s2).gettrace()]

        x.append(pl.mean(x_k))
        xerr.append(pl.std(x_k))

        y.append(pl.mean(y_k))
        yerr.append(pl.std(y_k))

        pl.text(x[-1], y[-1], " %s" % k, fontsize=8, alpha=0.4, zorder=-1)

    default_args = {"fmt": "o", "ms": 10}
    default_args.update(kwargs)
    pl.errorbar(x, y, xerr=xerr, yerr=yerr, **default_args)
    pl.xlabel(s1)
    pl.ylabel(s2)
开发者ID:aflaxman,项目名称:bednet_stock_and_flow,代码行数:30,代码来源:explore.py

示例11: compare_models

def compare_models(db, stoch="itn coverage", stat_func=None, plot_type="", **kwargs):
    if stat_func == None:
        stat_func = lambda x: x

    X = {}
    for k in sorted(db.keys()):
        c = k.split("_")[2]
        X[c] = []

    for k in sorted(db.keys()):
        c = k.split("_")[2]
        X[c].append([stat_func(x_ki) for x_ki in db[k].__getattribute__(stoch).gettrace()])

    x = pl.array([pl.mean(xc[0]) for xc in X.values()])
    xerr = pl.array([pl.std(xc[0]) for xc in X.values()])
    y = pl.array([pl.mean(xc[1]) for xc in X.values()])
    yerr = pl.array([pl.std(xc[1]) for xc in X.values()])

    if plot_type == "scatter":
        default_args = {"fmt": "o", "ms": 10}
        default_args.update(kwargs)
        for c in X.keys():
            pl.text(pl.mean(X[c][0]), pl.mean(X[c][1]), " %s" % c, fontsize=8, alpha=0.4, zorder=-1)
        pl.errorbar(x, y, xerr=xerr, yerr=yerr, **default_args)
        pl.xlabel("First Model")
        pl.ylabel("Second Model")
        pl.plot([0, 1], [0, 1], alpha=0.5, linestyle="--", color="k", linewidth=2)

    elif plot_type == "rel_diff":
        d1 = sorted(100 * (x - y) / x)
        d2 = sorted(100 * (xerr - yerr) / xerr)
        pl.subplot(2, 1, 1)
        pl.title("Percent Model 2 deviates from Model 1")

        pl.plot(d1, "o")
        pl.xlabel("Countries sorted by deviation in mean")
        pl.ylabel("deviation in mean (%)")

        pl.subplot(2, 1, 2)
        pl.plot(d2, "o")
        pl.xlabel("Countries sorted by deviation in std err")
        pl.ylabel("deviation in std err (%)")
    elif plot_type == "abs_diff":
        d1 = sorted(x - y)
        d2 = sorted(xerr - yerr)
        pl.subplot(2, 1, 1)
        pl.title("Percent Model 2 deviates from Model 1")

        pl.plot(d1, "o")
        pl.xlabel("Countries sorted by deviation in mean")
        pl.ylabel("deviation in mean")

        pl.subplot(2, 1, 2)
        pl.plot(d2, "o")
        pl.xlabel("Countries sorted by deviation in std err")
        pl.ylabel("deviation in std err")
    else:
        assert 0, "plot_type must be abs_diff, rel_diff, or scatter"

    return pl.array([x, y, xerr, yerr])
开发者ID:aflaxman,项目名称:bednet_stock_and_flow,代码行数:60,代码来源:explore.py

示例12: suplabel

def suplabel(axis, label, label_prop=None, labelpad=3, ha='center', va='center'):
    """
    Add super ylabel or xlabel to the figure
    Similar to matplotlib.suptitle
        axis       - string: "x" or "y"
        label      - string
        label_prop - keyword dictionary for Text
        labelpad   - padding from the axis (default: 5)
        ha         - horizontal alignment (default: "center")
        va         - vertical alignment (default: "center")
    """
    fig = pylab.gcf()
    xmin = []
    ymin = []
    for ax in fig.axes:
        xmin.append(ax.get_position().xmin)
        ymin.append(ax.get_position().ymin)
    xmin, ymin = min(xmin), min(ymin)
    dpi = fig.dpi
    if axis.lower() == "y":
        rotation = 90.
        x = xmin-float(labelpad)/dpi
        y = 0.5
    elif axis.lower() == 'x':
        rotation = 0.
        x = 0.5
        y = ymin - float(labelpad)/dpi
    else:
        raise Exception("Unexpected axis: x or y")
    if label_prop is None:
        label_prop = dict()
    pylab.text(x, y, label, rotation=rotation,
               transform=fig.transFigure,
               ha=ha, va=va,
               **label_prop)
开发者ID:alainmuls,项目名称:GNSSpy,代码行数:35,代码来源:plotCN0.py

示例13: PASTISConfMap

def PASTISConfMap(confmatrix):
    norms = np.sum(confmatrix,axis=1)

    for i in range(len(confmatrix[:,0])):
        confmatrix[i,:] /= norms[i]

    p.figure(12)
    p.clf()
    p.imshow(confmatrix,interpolation='nearest',origin='lower',cmap='YlOrRd')

    #box labels
    for x in range(len(confmatrix[:,0])):
        for y in range(len(confmatrix[:,0])):
            if confmatrix[y,x] > 0.05:
                if confmatrix[y,x]>0.7:
                    p.text(x,y,str(np.round(confmatrix[y,x],decimals=3)),va='center',ha='center',color='w')
                else:
                    p.text(x,y,str(np.round(confmatrix[y,x],decimals=3)),va='center',ha='center')

    #plot grid lines (using p.grid leads to unwanted offset)
    for x in [0.5,1.5,2.5,3.5,4.5]:
        p.plot([x,x],[-0.5,6.5],'k--')
    for y in [0.5,1.5,2.5,3.5,4.5]:
        p.plot([-0.5,6.5],[y,y],'k--')
    p.xlim(-0.5,5.5)
    p.ylim(-0.5,5.5)
    p.xlabel('Predicted Class')
    p.ylabel('True Class')

    #class labels
    p.xticks([0,1,2,3,4,5],['Planet', 'EB', 'ET', 'PSB','BEB', 'BTP'],rotation='vertical')
    p.yticks([0,1,2,3,4,5],['Planet', 'EB', 'ET', 'PSB','BEB', 'BTP'])

    
开发者ID:Soletmons,项目名称:TransitSOMTest,代码行数:32,代码来源:plottools.py

示例14: plotVowelProportionHistogram

def plotVowelProportionHistogram(wordList, numBins=15):
    """
    Plots a histogram of the proportion of vowels in each word in wordList
    using the specified number of bins in numBins
    """
    vowels = 'aeiou'
    vowelProportions = []

    for word in wordList:
        vowelsCount = 0.0

        for letter in word:
            if letter in vowels:
                vowelsCount += 1

        vowelProportions.append(vowelsCount / len(word))

    meanProportions = sum(vowelProportions) / len(vowelProportions)
    print "Mean proportions: ", meanProportions

    pylab.figure(1)
    pylab.hist(vowelProportions, bins=15)
    pylab.title("Histogram of Proportions of Vowels in Each Word")
    pylab.ylabel("Count of Words in Each Bucket")
    pylab.xlabel("Proportions of Vowels in Each Word")

    ymin, ymax = pylab.ylim()
    ymid = (ymax - ymin) / 2
    pylab.text(0.03, ymid, "Mean = {0}".format(
        str(round(meanProportions, 4))))
    pylab.vlines(0.5, 0, ymax)
    pylab.text(0.51, ymax - 0.01 * ymax, "0.5", verticalalignment = 'top')

    pylab.show()
开发者ID:eshilts,项目名称:intro-to-cs-6.00x,代码行数:34,代码来源:histogramfun.py

示例15: bondlengths

def bondlengths(Ea, dE):
    """Calculate bond lengths and write to bondlengths.csv file"""
    B = []
    E0 = []
    csv = open('bondlengths.csv', 'w')
    for formula, energies in dE:
        bref = diatomic[formula][1]
        b = np.linspace(0.96 * bref, 1.04 * bref, 5)
        e = np.polyfit(b, energies, 3)
        if not formula in Ea:
            continue
        ea, eavasp = Ea[formula]
        dedb = np.polyder(e, 1)
        b0 = np.roots(dedb)[1]
        assert abs(b0 - bref) < 0.1
        b = np.linspace(0.96 * bref, 1.04 * bref, 20)
        e = np.polyval(e, b) - ea
        if formula == 'O2':
            plt.plot(b, e, '-', color='0.7', label='GPAW')
        else:
            plt.plot(b, e, '-', color='0.7', label='_nolegend_')
        name = latex(data[formula]['name'])
        plt.text(b[0], e[0] + 0.2, name)
        B.append(bref)
        E0.append(-eavasp)
        csv.write('`%s`, %.3f, %.3f, %+.3f\n' %
                  (name[1:-1], b0, bref, b0 - bref))
        
    plt.plot(B, E0, 'g.', label='reference')
    plt.legend(loc='lower right')
    plt.xlabel('Bond length $\mathrm{\AA}$')
    plt.ylabel('Energy [eV]')
    plt.savefig('bondlengths.png')
开发者ID:ryancoleman,项目名称:lotsofcoresbook2code,代码行数:33,代码来源:make_csv_files.py


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