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


Python seaborn.factorplot方法代码示例

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


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

示例1: plot_mushra_boxplots

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def plot_mushra_boxplots(data, size=5, output_file=None):
    """
    Plot the MUSHRA ratings as a grid of boxplots. If `output_file` is defined, then save the plot to file.

    Parameters
    ----------
    data: pandas.DataFrame
        The ratings data obtained from `get_ratings_data`.

    size : float
        Height of each boxplot in inches. (default is 5)

    output_file: str
        Path to the output file location. (default is None)

    Returns
    -------
    g : seaborn.axisgrid.FacetGrid
    """
    g = sns.factorplot(x='stimulus', y='rating', data=data, row='condition_id', kind='box', notch=True, size=size)
    g.set(ylim=(app.config['MIN_RATING_VALUE'], app.config['MAX_RATING_VALUE']))

    if output_file is not None:
        g.savefig(output_file) 
开发者ID:interactiveaudiolab,项目名称:CAQE,代码行数:26,代码来源:analysis.py

示例2: _plotWeekdayStats

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def _plotWeekdayStats(stats, columns, groupBy=True):
    dataToPlot = stats.copy()
    # Group by weekday and rename date column
    if groupBy:
        dataToPlot = dataToPlot.groupby(stats['date'].dt.weekday).mean()
        dataToPlot = dataToPlot.reset_index().rename(columns={'date':'weekday'})

    # change stats from columns to row attribute
    dataToPlot = pd.melt(dataToPlot, id_vars=['weekday'], value_vars=columns,
                         var_name='stats', value_name='val')
    # Rename stats and weekdays
    dataToPlot['stats'].replace(NAMES, inplace=True)
    dataToPlot['weekday'].replace(dayOfWeek, inplace=True)
    # Plot
    g = sns.factorplot(data=dataToPlot, x="weekday", y="val", col="stats",
                       order=dayOfWeekOrder, kind="point", sharey=False, col_wrap=3)
    g.set_xticklabels(rotation=45)
    g.set(xlabel='')
    return g
    #sns.plt.show() 
开发者ID:5agado,项目名称:fitbit-analyzer,代码行数:22,代码来源:plotting.py

示例3: plotYearAndMonthStatsSleep

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def plotYearAndMonthStatsSleep(stats, columns=None):
    """
    Plot aggregated (mean) stats by year and month.
    :param stats: data to plot
    """
    if not columns:
        columns = ['sleep_efficiency', 'sleep_hours']

    dataToPlot = _prepareYearAndMonthStats(stats, columns)
    # Plot
    g = sns.factorplot(data=dataToPlot, x="date", y="val", row="stats", kind="point", sharey=False)
    g.set_xticklabels(rotation=45)
    for ax in g.axes.flat:
        ax.grid(b=True)
    return g
    #sns.plt.show() 
开发者ID:5agado,项目名称:fitbit-analyzer,代码行数:18,代码来源:plotting.py

示例4: plot_summary

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def plot_summary(summary_only, stats_dir, output):
    import seaborn as sns
    rows = parse_data(stats_dir)
    g = sns.factorplot(y='result', x='score', col='experiment',
                       data=rows, kind='bar', ci=None,
                       order=ANSWER_PLOT_ORDER, size=4, col_wrap=4, sharex=False)
    for ax in g.axes.flat:
        for label in ax.get_xticklabels():
            label.set_rotation(30)
    plt.subplots_adjust(top=0.93)
    g.fig.suptitle('Feature Ablation Study')
    g.savefig(output, format='png', dpi=200) 
开发者ID:Pinafore,项目名称:qb,代码行数:14,代码来源:performance.py

示例5: factorplot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def factorplot(labels,data,name,):
    sb.set_style("whitegrid",{'grid.linewidth': 3.,
                            'axes.edgecolor':'0.0','grid.edgecolor':'0.0'})
    g = sb.factorplot(labels[0],labels[1],labels[2],kind='bar', data=data,legend_out=False,palette=cp,
                     hue_order = ['Oracle','TACO',"Naive (MLP)","Naive (GRU)"] )

    sb.set_style("whitegrid")

    g.set(ylim = (0,1))
    g.set(xlim=(-0.45, 3.01))
    g.fig.set_size_inches(15,8)
    plt.legend(loc='best')
    g.savefig(name+'.pdf') 
开发者ID:KyriacosShiarli,项目名称:taco,代码行数:15,代码来源:plotting.py

示例6: tm_gene_family_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def tm_gene_family_plot(tm_data, ordered_genomes, biotypes, gene_family_tgt):
    """transMap gene family collapse plots."""
    try:
        df = json_biotype_nested_counter_to_df(tm_data, 'Gene Family Collapse')
    except ValueError:  # no gene family collapse. probably the test set.
        with gene_family_tgt.open('wb') as outf:
            pass
        return
    df['Gene Family Collapse'] = pd.to_numeric(df['Gene Family Collapse'])
    tot_df = df[['Gene Family Collapse', 'genome', 'count']].\
        groupby(['genome', 'Gene Family Collapse']).aggregate(sum).reset_index()
    tot_df = tot_df.sort_values('Gene Family Collapse')
    af = luigi.local_target.atomic_file(gene_family_tgt.path)
    with PdfPages(af.tmp_path) as pdf:
        g = sns.factorplot(y='count', col='genome', x='Gene Family Collapse', data=tot_df, kind='bar',
                           col_order=ordered_genomes, col_wrap=4)
        g.fig.suptitle('Number of genes collapsed during gene family collapse')
        g.set_xlabels('Number of genes collapsed to one locus')
        g.set_ylabels('Number of genes')
        g.fig.subplots_adjust(top=0.9)
        multipage_close(pdf, tight_layout=False)
        for biotype in biotypes:
            biotype_df = biotype_filter(df, biotype)
            if biotype_df is None:
                continue
            biotype_df = biotype_df.sort_values('Gene Family Collapse')
            g = sns.factorplot(y='count', col='genome', x='Gene Family Collapse', data=biotype_df, kind='bar',
                               col_order=[x for x in ordered_genomes if x in set(biotype_df.genome)], col_wrap=4)
            g.fig.suptitle('Number of genes collapsed during gene family collapse for {}'.format(biotype))
            g.set_xlabels('Number of genes collapsed to one locus')
            g.set_ylabels('Number of genes')
            g.fig.subplots_adjust(top=0.9)
            multipage_close(pdf, tight_layout=False)
    af.move_to_final_destination() 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:36,代码来源:plots.py

示例7: denovo_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def denovo_plot(consensus_data, ordered_genomes, denovo_tgt):
    af = luigi.local_target.atomic_file(denovo_tgt.path)
    with PdfPages(af.tmp_path) as pdf:
        try:
            df = json_biotype_nested_counter_to_df(consensus_data, 'denovo')
        except ValueError:
            # No de novo results. Probably the test set.
            return
        # fix column names because json_biotype_nested_counter_to_df makes assumptions
        df.columns = ['Result', 'Number of transcripts', 'Augustus mode', 'genome']
        has_pb = len(set(df['Augustus mode'])) == 2
        if len(set(df.genome)) > 1:  # if we ran in PB only, we may not have multiple genomes
            if has_pb is True:
                ax = sns.factorplot(data=df, x='genome', y='Number of transcripts', kind='bar', col='Result',
                                    hue='Augustus mode', col_wrap=2, row_order=ordered_genomes, sharex=True,
                                    sharey=False)
            else:
                ax = sns.factorplot(data=df, x='genome', y='Number of transcripts', kind='bar', col='Result',
                                    col_wrap=2, row_order=ordered_genomes, sharex=True, sharey=False)
        else:
            if has_pb is True:
                ax = sns.factorplot(data=df, x='Result', y='Number of transcripts', kind='bar', hue='Augustus mode')
            else:
                ax = sns.factorplot(data=df, x='Result', y='Number of transcripts', kind='bar')
        ax.set_xticklabels(rotation=90)
        ax.fig.suptitle('Incorporation of de-novo predictions')
        ax.fig.subplots_adjust(top=0.9)
        multipage_close(pdf, tight_layout=False)
    af.move_to_final_destination() 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:31,代码来源:plots.py

示例8: pb_support_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def pb_support_plot(consensus_data, ordered_genomes, pb_genomes, pb_support_tgt):
    af = luigi.local_target.atomic_file(pb_support_tgt.path)
    with PdfPages(af.tmp_path) as pdf:
        pb_genomes = [x for x in ordered_genomes if x in pb_genomes]  # fix order
        df = json_biotype_counter_to_df(consensus_data, 'IsoSeq Transcript Validation')
        if len(df) == 0:
            # no support information
            return
        df.columns = ['IsoSeq Transcript Validation', 'Number of transcripts', 'genome']
        ax = sns.factorplot(data=df, x='genome', y='Number of transcripts', hue='IsoSeq Transcript Validation',
                            kind='bar', row_order=pb_genomes)
        ax.set_xticklabels(rotation=90)
        ax.fig.suptitle('Isoforms validated by at least one IsoSeq read')
        multipage_close(pdf, tight_layout=False)
    af.move_to_final_destination() 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:17,代码来源:plots.py

示例9: indel_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def indel_plot(consensus_data, ordered_genomes, indel_plot_tgt):
    af = luigi.local_target.atomic_file(indel_plot_tgt.path)
    with PdfPages(af.tmp_path) as pdf:
        tm_df = pd.concat([pd.DataFrame.from_dict(consensus_data[genome]['transMap Indels'], orient='index').T
                           for genome in ordered_genomes])
        try:  # this is a hack to deal with weird small input datasets
            tm_df['genome'] = ordered_genomes
        except:
            return
        tm_df['transcript set'] = ['transMap'] * len(tm_df)
        consensus_df = pd.concat([pd.DataFrame.from_dict(consensus_data[genome]['Consensus Indels'], orient='index').T
                                  for genome in ordered_genomes])
        consensus_df['genome'] = ordered_genomes
        consensus_df['transcript set'] = ['Consensus'] * len(consensus_df)
        df = pd.concat([consensus_df, tm_df])
        df = pd.melt(df, id_vars=['genome', 'transcript set'],
                     value_vars=['CodingDeletion', 'CodingInsertion', 'CodingMult3Indel'])
        df.columns = ['Genome', 'Transcript set', 'Type', 'Percent of transcripts']
        g = sns.factorplot(data=df, x='Genome', y='Percent of transcripts', col='Transcript set',
                           hue='Type', kind='bar', row_order=ordered_genomes,
                           col_order=['transMap', 'Consensus'])
        g.set_xticklabels(rotation=90)
        g.fig.subplots_adjust(top=.8)
        g.fig.suptitle('Coding indels')
        multipage_close(pdf, tight_layout=False)
    af.move_to_final_destination()


###
# shared plotting functions
### 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:33,代码来源:plots.py

示例10: read_length_distributions

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def read_length_distributions(path, refs):
    """Get read lengths for all aligned files in path mapped
       to ref db names, assumes the fasta files and sam files are present in the
       target folder
    """

    files = glob.glob(path+'/*.fa')
    fnames = [os.path.splitext(os.path.basename(f))[0] for f in files]
    fnames = [i for i in fnames if not i.endswith('_r')]
    print (fnames)

    res = []
    for n in fnames:
        x = get_aligned_reads_lengths(path, n, refs)
        x = x.ix[10:40]
        x['file'] = n
        res.append(x)
    res = pd.concat(res)
    res = res.reset_index()
    #print res[:60]
    #plot histograms
    m = pd.melt(res, id_vars=['file','length'], value_vars=refs,
                var_name='ref', value_name='freq')
    g = sns.factorplot(y='freq',x='length', data=m, row='ref', kind="bar",
                        size=2,aspect=4,sharex=False,palette='Blues_d')
    plt.savefig(os.path.join(path,'read_lengths.png'))
    return res 
开发者ID:dmnfarrell,项目名称:smallrnaseq,代码行数:29,代码来源:analysis.py

示例11: dist_from_hyperplane_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def dist_from_hyperplane_plot(stats_output):
    """ Plot SVM Classification Distance from Hyperplane

    Args:
        stats_output: a pandas file with prediction output

    Returns:
        fig: Will return a seaborn plot of distance from hyperplane

    """

    if "dist_from_hyperplane_xval" in stats_output.columns:
        sns.factorplot(
            "subject_id",
            "dist_from_hyperplane_xval",
            hue="Y",
            data=stats_output,
            kind="point",
        )
    else:
        sns.factorplot(
            "subject_id",
            "dist_from_hyperplane_all",
            hue="Y",
            data=stats_output,
            kind="point",
        )
    plt.xlabel("Subject", fontsize=16)
    plt.ylabel("Distance from Hyperplane", fontsize=16)
    plt.title("Classification", fontsize=18)
    return 
开发者ID:cosanlab,项目名称:nltools,代码行数:33,代码来源:plotting.py

示例12: plot_boxplot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def plot_boxplot(ds, cat, num):
    sns.set()
    plt.gcf().clear()
    with sns.axes_style(style='ticks'):
        sns.factorplot(cat, num, data=ds, kind="box")
    from io import BytesIO
    plt.xlabel(cat)
    plt.ylabel(num)
    figfile = BytesIO()
    plt.savefig(figfile, format='png')
    figfile.seek(0)  # rewind to beginning of file
    import base64
    figdata_png = base64.b64encode(figfile.getvalue())
    return figdata_png 
开发者ID:alvarodemig,项目名称:DataScience-webapp-with-flask,代码行数:16,代码来源:plotfunctions.py

示例13: plot_active_cells

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def plot_active_cells(active):
    fg = sns.factorplot(data=active, x='segment_id', y='active', hue='group', col='session_id', sharey=True, order=['first', 'second', 'third', 'fourth', 'last'])
    return fg 
开发者ID:DeniseCaiLab,项目名称:minian,代码行数:5,代码来源:plot.py

示例14: consensus_support_plot

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def consensus_support_plot(consensus_data, ordered_genomes, biotypes, modes, title, tgt):
    """grouped violin plots of original intron / intron annotation / exon annotation support"""
    def adjust_plot(g, this_title):
        g.set_xticklabels(rotation=90)
        g.fig.suptitle(this_title)
        g.fig.subplots_adjust(top=0.9)
        for ax in g.axes.flat:
            ax.set_ylabel('Percent supported')
            ax.set_ylim(-1, 101)

    dfs = []
    for i, mode in enumerate(modes):
        df = json_to_df_with_biotype(consensus_data, mode)
        if i > 0:
            df = df[mode]
        dfs.append(df)
    df = pd.concat(dfs, axis=1)
    df = pd.melt(df, value_vars=modes, id_vars=['genome', 'biotype'])
    af = luigi.local_target.atomic_file(tgt.path)
    with PdfPages(af.tmp_path) as pdf:
        if len(ordered_genomes) > 1:
            g = sns.factorplot(data=df, y='value', x='genome', col='variable', col_wrap=2, kind='violin', sharex=True,
                               sharey=True, row_order=ordered_genomes, cut=0)
        else:
            g = sns.factorplot(data=df, y='value', x='variable', kind='violin', sharex=True,
                               sharey=True, row_order=ordered_genomes, cut=0)
        adjust_plot(g, title)
        multipage_close(pdf, tight_layout=False)
        title += ' for {}'
        for biotype in biotypes:
            this_title = title.format(biotype)
            biotype_df = biotype_filter(df, biotype)
            if biotype_df is not None:
                if len(ordered_genomes) > 1:
                    g = sns.factorplot(data=biotype_df, y='value', x='genome', col='variable', col_wrap=2,
                                       kind='violin', sharex=True, sharey=True, row_order=ordered_genomes, cut=0)
                else:
                    g = sns.factorplot(data=df, y='value', x='variable', kind='violin', sharex=True,
                                       sharey=True, row_order=ordered_genomes, cut=0)
                adjust_plot(g, this_title)
                multipage_close(pdf, tight_layout=False)
    af.move_to_final_destination() 
开发者ID:ComparativeGenomicsToolkit,项目名称:Comparative-Annotation-Toolkit,代码行数:44,代码来源:plots.py

示例15: _plotMonthlyStats

# 需要导入模块: import seaborn [as 别名]
# 或者: from seaborn import factorplot [as 别名]
def _plotMonthlyStats(stats, columns, groupBy=True):
    dataToPlot = stats.copy()
    # Group by month and rename date column
    if groupBy:
        dataToPlot = dataToPlot.groupby(stats['date'].dt.month).mean()
        dataToPlot = dataToPlot.reset_index().rename(columns={'date': 'month'})

    # change stats from columns to row attribute
    dataToPlot = pd.melt(dataToPlot, id_vars=['month'], value_vars=columns,
                         var_name='stats', value_name='val')
    # Rename stats and weekdays
    dataToPlot['stats'].replace(NAMES, inplace=True)
    dataToPlot['month'].replace(months, inplace=True)
    order = [m for m in monthsOrder if m in dataToPlot['month'].unique()]
    # Plot
    g = sns.factorplot(data=dataToPlot, x="month", y="val", col="stats", order=order, kind="bar", sharey=False)
    g.set_xticklabels(rotation=45)
    g.set(xlabel='')
    return g
    #sns.plt.show()

# def _plotMonthlyStats(stats, columns):
#     """
#     Plot aggregated (mean) stats by month
#     :param stats: data to plot
#     :param columns: columns from stats to plot
#     """
#     MEASURE_NAME = 'month'
#     months={1:'Jan', 2:'Feb', 3:'Mar', 4:'Apr', 5:'May', 6:'Jun', 7:'Jul', 8:'Aug',
#             9:'Sep', 10:'Oct', 11:'Nov', 12:'Dec'}
#     order = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']
#     stats[MEASURE_NAME] = stats[MEASURE_NAME].map(months)
#
#     order = [m for m in order if m in stats[MEASURE_NAME].unique()]
#
#     f, axes = getAxes(2,2)
#     for i, c in enumerate(columns):
#         if c in NAMES:
#             c = NAMES[c]
#         g = sns.barplot(x=MEASURE_NAME, y=c, data=stats, order=order, ax=axes[i])
#         g.set_xlabel('')
#     sns.plt.show() 
开发者ID:5agado,项目名称:fitbit-analyzer,代码行数:44,代码来源:plotting.py


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