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


Python pylab.tight_layout方法代码示例

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


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

示例1: plot_hits

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_hits(filename_fil, filename_dat):
    """ Plot the hits in a .dat file. """
    table = find_event.read_dat(filename_dat)
    print(table)

    plt.figure(figsize=(10, 8))
    N_hit = len(table)
    if N_hit > 10:
        print("Warning: More than 10 hits found. Only plotting first 10")
        N_hit = 10

    for ii in range(N_hit):
        plt.subplot(N_hit, 1, ii+1)
        plot_event.plot_hit(filename_fil, filename_dat, ii)
    plt.tight_layout()
    plt.savefig(filename_dat.replace('.dat', '.png'))
    plt.show() 
开发者ID:UCBerkeleySETI,项目名称:turbo_seti,代码行数:19,代码来源:test_turbo_seti.py

示例2: heatmap

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def heatmap(df,fname=None,cmap='seismic',log=False):
    """Plot a heat map"""

    from matplotlib.colors import LogNorm
    f=plt.figure(figsize=(8,8))
    ax=f.add_subplot(111)
    norm=None
    df=df.replace(0,.1)
    if log==True:
        norm=LogNorm(vmin=df.min().min(), vmax=df.max().max())
    hm = ax.pcolor(df,cmap=cmap,norm=norm)
    plt.colorbar(hm,ax=ax,shrink=0.6,norm=norm)
    plt.yticks(np.arange(0.5, len(df.index), 1), df.index)
    plt.xticks(np.arange(0.5, len(df.columns), 1), df.columns, rotation=90)
    #ax.axvline(4, color='gray'); ax.axvline(8, color='gray')
    plt.tight_layout()
    if fname != None:
        f.savefig(fname+'.png')
    return ax 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:21,代码来源:plotting.py

示例3: plot_fractions

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_fractions(df, label=None):
    """Process results of multiple mappings to get fractions
    of each annotations mapped
    label: plot this sample only"""

    fig,ax = plt.subplots(figsize=(8,8))
    df = df.set_index('label')
    df = df._get_numeric_data()
    if len(df) == 1:
        label = df.index[0]
    if label != None:
        ax = df.T.plot(y=label,kind='pie',colormap='Spectral',autopct='%.1f%%',
                      startangle=0, labels=None,legend=True,pctdistance=1.1,
                      fontsize=10, ax=ax)
    else:
        ax = df.plot(kind='barh',stacked=True,linewidth=0,cmap='Spectral',ax=ax)
        #ax.legend(ncol=2)
        ax.set_position([0.2,0.1,0.6,0.8])
        ax.legend(loc="best",bbox_to_anchor=(1.0, .9))
    plt.title('fractions mapped')
    #plt.tight_layout()
    return fig 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:24,代码来源:plotting.py

示例4: plot_read_count_dists

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_read_count_dists(counts, h=8, n=50):
    """Boxplots of read count distributions """

    scols,ncols = base.get_column_names(counts)
    df = counts.sort_values(by='mean_norm',ascending=False)[:n]
    df = df.set_index('name')[ncols]
    t = df.T
    w = int(h*(len(df)/60.0))+4
    fig, ax = plt.subplots(figsize=(w,h))
    if len(scols) > 1:
        sns.stripplot(data=t,linewidth=1.0,palette='coolwarm_r')
        ax.xaxis.grid(True)
    else:
        df.plot(kind='bar',ax=ax)
    sns.despine(offset=10,trim=True)
    ax.set_yscale('log')
    plt.setp(ax.xaxis.get_majorticklabels(), rotation=90)
    plt.ylabel('read count')
    #print (df.index)
    #plt.tight_layout()
    fig.subplots_adjust(bottom=0.2,top=0.9)
    return fig 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:24,代码来源:plotting.py

示例5: summarise_reads

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def summarise_reads(path):
    """Count reads in all files in path"""

    resultfile = os.path.join(path, 'read_stats.csv')
    files = glob.glob(os.path.join(path,'*.fastq'))
    vals=[]
    rl=[]
    for f in files:
        label = os.path.splitext(os.path.basename(f))[0]
        s = utils.fastq_to_dataframe(f)
        l = len(s)
        vals.append([label,l])
        print (label, l)

    df = pd.DataFrame(vals,columns=['path','total reads'])
    df.to_csv(resultfile)
    df.plot(x='path',y='total reads',kind='barh')
    plt.tight_layout()
    plt.savefig(os.path.join(path,'total_reads.png'))
    #df = pd.concat()
    return df 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:23,代码来源:analysis.py

示例6: plot_pca

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_pca(pX, palette='Spectral', labels=None, ax=None, colors=None):
    """Plot PCA result, input should be a dataframe"""

    if ax==None:
        fig,ax=plt.subplots(1,1,figsize=(6,6))
    cats = pX.index.unique()
    colors = sns.mpl_palette(palette, len(cats)+1)
    print (len(cats), len(colors))
    for c, i in zip(colors, cats):
        #print (i, len(pX.ix[i]))
        #if not i in pX.index: continue
        ax.scatter(pX.ix[i, 0], pX.ix[i, 1], color=c, s=90, label=i,
                   lw=.8, edgecolor='black', alpha=0.8)
    ax.set_xlabel('PC1')
    ax.set_ylabel('PC2')
    i=0
    if labels is not None:
        for n, point in pX.iterrows():
            l=labels[i]
            ax.text(point[0]+.1, point[1]+.1, str(l),fontsize=(9))
            i+=1
    ax.legend(fontsize=10,bbox_to_anchor=(1.5, 1.05))
    sns.despine()
    plt.tight_layout()
    return 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:27,代码来源:analysis.py

示例7: plot_confusion_matrices

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_confusion_matrices(y_true, y_pred, size=12):
    """plot_confusion_matrices."""
    plt.figure(figsize=(size, size))
    plt.subplot(121)
    plot_confusion_matrix(y_true, y_pred, normalize=False)
    plt.subplot(122)
    plot_confusion_matrix(y_true, y_pred, normalize=True)
    plt.tight_layout(w_pad=5)
    plt.show() 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:11,代码来源:__init__.py

示例8: plot_aucs

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_aucs(y_true, y_score, size=12):
    """plot_confusion_matrices."""
    plt.figure(figsize=(size, size / 2.0))
    plt.subplot(121, aspect='equal')
    plot_roc_curve(y_true, y_score)
    plt.subplot(122, aspect='equal')
    plot_precision_recall_curve(y_true, y_score)
    plt.tight_layout(w_pad=5)
    plt.show() 
开发者ID:fabriziocosta,项目名称:EDeN,代码行数:11,代码来源:__init__.py

示例9: plot_mesh

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_mesh(mesh, *whats, show=True, plot=None):
    for what in [update_plot] + list(whats):
        plot = what(mesh, plot)
    if show:
        li = max(plot[1][1], plot[1][3], plot[1][5])
        plot[0].auto_scale_xyz([0, li], [0, li], [0, li])
        pl.tight_layout()
        pl.show()
    return plot 
开发者ID:ranahanocka,项目名称:MeshCNN,代码行数:11,代码来源:mesh_viewer.py

示例10: solid_plot

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def solid_plot():
	# reference values, see
	sref=0.0924102
	wref=0.000170152
	# List of the element types to process (text files)
	eltyps=["C3D8",
		"C3D8R",
		"C3D8I",
		"C3D20",
		"C3D20R",
		"C3D4",
		"C3D10"]
	pylab.figure(figsize=(10, 5.0), dpi=100)
	pylab.subplot(1,2,1)
	pylab.title("Stress")
	# pylab.hold(True) # deprecated
	for elty in eltyps:
		data = numpy.genfromtxt(elty+".txt")
		pylab.plot(data[:,1],data[:,2]/sref,"o-")
	pylab.xscale("log")
	pylab.xlabel('Number of nodes')
	pylab.ylabel('Max $\sigma / \sigma_{\mathrm{ref}}$')
	pylab.grid(True)
	pylab.subplot(1,2,2)
	pylab.title("Displacement")
	# pylab.hold(True) # deprecated
	for elty in eltyps:
		data = numpy.genfromtxt(elty+".txt")
		pylab.plot(data[:,1],data[:,3]/wref,"o-")
	pylab.xscale("log")
	pylab.xlabel('Number of nodes')
	pylab.ylabel('Max $u / u_{\mathrm{ref}}$')
	pylab.ylim([0,1.2])
	pylab.grid(True)
	pylab.legend(eltyps,loc="lower right")
	pylab.tight_layout()
	pylab.savefig("solid.svg",format="svg")
	# pylab.show()


# Move new files and folders to 'Refs' 
开发者ID:mkraska,项目名称:CalculiX-Examples,代码行数:43,代码来源:test.py

示例11: plot_parametertrace_algorithms

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_parametertrace_algorithms(result_lists, algorithmnames, spot_setup, 
                                   fig_name='parametertrace_algorithms.png'):
    """Example Plot as seen in the SPOTPY Documentation"""
    import matplotlib.pyplot as plt
    font = {'family' : 'calibri',
        'weight' : 'normal',
        'size'   : 20}
    plt.rc('font', **font)
    fig=plt.figure(figsize=(17,5))
    subplots=len(result_lists)
    parameter = spotpy.parameter.get_parameters_array(spot_setup)
    rows=len(parameter['name'])
    for j in range(rows):
        for i in range(subplots):
            ax  = plt.subplot(rows,subplots,i+1+j*subplots)
            data=result_lists[i]['par'+parameter['name'][j]]
            ax.plot(data,'b-')
            if i==0:
                ax.set_ylabel(parameter['name'][j])
                rep = len(data)
            if i>0:
                ax.yaxis.set_ticks([])
            if j==rows-1:
                ax.set_xlabel(algorithmnames[i-subplots])
            else:
                ax.xaxis.set_ticks([])
            ax.plot([1]*rep,'r--')
            ax.set_xlim(0,rep)
            ax.set_ylim(parameter['minbound'][j],parameter['maxbound'][j])
            
    #plt.tight_layout()
    fig.savefig(fig_name, bbox_inches='tight') 
开发者ID:thouska,项目名称:spotpy,代码行数:34,代码来源:analyser.py

示例12: plot_objectivefunctiontraces

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_objectivefunctiontraces(results,evaluation,algorithms,fig_name='Like_trace.png'):
    import matplotlib.pyplot as plt
    from matplotlib import colors
    cnames=list(colors.cnames)
    font = {'family' : 'calibri',
        'weight' : 'normal',
        'size'   : 20}
    plt.rc('font', **font)
    fig=plt.figure(figsize=(16,3))
    xticks=[5000,15000]

    for i in range(len(results)):
        ax  = plt.subplot(1,len(results),i+1)
        likes=calc_like(results[i],evaluation,spotpy.objectivefunctions.rmse)
        ax.plot(likes,'b-')
        ax.set_ylim(0,25)
        ax.set_xlim(0,len(results[0]))
        ax.set_xlabel(algorithms[i])
        ax.xaxis.set_ticks(xticks)
        if i==0:
            ax.set_ylabel('RMSE')
            ax.yaxis.set_ticks([0,10,20])
        else:
            ax.yaxis.set_ticks([])

    plt.tight_layout()
    fig.savefig(fig_name) 
开发者ID:thouska,项目名称:spotpy,代码行数:29,代码来源:analyser.py

示例13: plot_sample_variation

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_sample_variation(df):

    fig,axs=plt.subplots(2,1,figsize=(6,6))
    axs=axs.flat
    cols,ncols = mirdeep2.get_column_names(m)
    x = m.ix[2][cols]
    x.plot(kind='bar',ax=axs[0])
    x2 = m.ix[2][ncols]
    x2.plot(kind='bar',ax=axs[1])
    sns.despine(trim=True,offset=10)
    plt.tight_layout()
    return fig 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:14,代码来源:plotting.py

示例14: plot_sample_counts

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def plot_sample_counts(counts):

    fig,ax = plt.subplots(figsize=(10,6))
    scols,ncols = base.get_column_names(counts)
    counts[scols].sum().plot(kind='bar',ax=ax)
    plt.title('total counts per sample (unnormalised)')
    plt.tight_layout()
    return fig 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:10,代码来源:plotting.py

示例15: analyse_results

# 需要导入模块: import pylab [as 别名]
# 或者: from pylab import tight_layout [as 别名]
def analyse_results(k,n,outpath=None):
    """Summarise multiple results"""

    if outpath != None:
        os.chdir(outpath)
    #add mirbase info
    k = k.merge(mirbase,left_on='name',right_on='mature1')
    ky1 = 'unique reads'
    ky2 = 'read count' #'RC'
    cols = ['name','freq','mean read count','mean_norm','total','perc','mirbase_id']
    print
    print ('found:')
    idcols,normcols = get_column_names(k)
    final = filter_expr_results(k,freq=.8,meanreads=200)
    print (final[cols])
    print ('-------------------------------')
    print ('%s total' %len(k))
    print ('%s with >=10 mean reads' %len(k[k['mean read count']>=10]))
    print ('%s found in 1 sample only' %len(k[k['freq']==1]))
    print ('top 10 account for %2.2f' %k['perc'][:10].sum())

    fig,ax = plt.subplots(nrows=1, ncols=1, figsize=(8,6))
    k.set_index('name')['total'][:10].plot(kind='barh',colormap='Spectral',ax=ax,log=True)
    plt.tight_layout()
    fig.savefig('srnabench_top_known.png')
    #fig = plot_read_count_dists(final)
    #fig.savefig('srnabench_known_counts.png')
    fig,ax = plt.subplots(figsize=(10,6))
    k[idcols].sum().plot(kind='bar',ax=ax)
    fig.savefig('srnabench_total_persample.png')
    print
    k.to_csv('srnabench_known_all.csv',index=False)
    return k 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:35,代码来源:srnabench.py


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