當前位置: 首頁>>代碼示例>>Python>>正文


Python graph_objs.Box方法代碼示例

本文整理匯總了Python中plotly.graph_objs.Box方法的典型用法代碼示例。如果您正苦於以下問題:Python graph_objs.Box方法的具體用法?Python graph_objs.Box怎麽用?Python graph_objs.Box使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在plotly.graph_objs的用法示例。


在下文中一共展示了graph_objs.Box方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: create_trace

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Box [as 別名]
def create_trace(settings):
        # flip the variables according to the box orientation

        if settings.properties['box_orientation'] == 'h':
            y = settings.x
            x = settings.y
        else:
            x = settings.x
            y = settings.y

        return [graph_objs.Box(
            x=x or None,
            y=y,
            name=settings.data_defined_legend_title if settings.data_defined_legend_title != '' else settings.properties['name'],
            customdata=settings.properties['custom'],
            boxmean=settings.properties['box_stat'],
            orientation=settings.properties['box_orientation'],
            boxpoints=settings.properties['box_outliers'],
            fillcolor=settings.data_defined_colors[0] if settings.data_defined_colors else settings.properties['in_color'],
            line={'color': settings.data_defined_stroke_colors[0] if settings.data_defined_stroke_colors else settings.properties['out_color'],
                  'width': settings.data_defined_stroke_widths[0] if settings.data_defined_stroke_widths else settings.properties['marker_width']},
            opacity=settings.properties['opacity']
        )] 
開發者ID:ghtmtt,項目名稱:DataPlotly,代碼行數:25,代碼來源:box.py

示例2: calc_graph

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Box [as 別名]
def calc_graph(self):
        # main data about technologies
        data = self.process_individual_ramping_capacity()
        hours = data.index.hour
        graph = []
        for field in self.analysis_fields:
            y = data[field].values / 1E6  # into MW
            trace = go.Box(x=hours, y=y, name=NAMING[field], marker=dict(color=COLOR[field]))
            graph.append(trace)

        return graph 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:13,代碼來源:g_grid_ramping_capacity.py

示例3: name

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Box [as 別名]
def name():
        return PlotType.tr('Box Plot') 
開發者ID:ghtmtt,項目名稱:DataPlotly,代碼行數:4,代碼來源:box.py

示例4: plot_ngenes

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Box [as 別名]
def plot_ngenes(input_gffs, outdir):

    # get simplified file names
    file_names = [
        os.path.splitext(os.path.basename(gff))[0] for gff in input_gffs
    ]

    # count genes
    ngenes = np.zeros(len(input_gffs))
    for i, gff_file in enumerate(input_gffs):
        with open(gff_file, 'r') as gff:
            for line in gff:
                if "##FASTA" in line: break
                if "##" == line[:2]: continue
                if "CDS" not in line: continue
                ngenes[i] += 1

    with open(outdir + "ngenes.txt", "w") as genes_out:
        genes_out.write("sample\tno_genes\n")
        for i, j in zip(file_names, ngenes):
            genes_out.write("%s\t%s\n" % (i, j))
    # generate static plot
    plt.style.use('ggplot')
    fig = plt.figure()
    plt.barh(np.arange(len(ngenes)), ngenes)
    plt.yticks(np.arange(len(ngenes)), file_names)
    plt.grid(True)
    plt.ylabel("File Name")
    plt.xlabel("Number of Genes")
    plt.tight_layout()
    fig.savefig(outdir + "ngenes_barplot.png")

    # generate interactive boxplot
    data = [
        go.Box(y=ngenes,
               text=file_names,
               hoverinfo="text",
               boxpoints='all',
               jitter=0.3,
               pointpos=-1.8)
    ]
    layout = go.Layout(autosize=True,
                       xaxis=dict(title='',
                                  titlefont=dict(size=18, color='black'),
                                  showticklabels=False,
                                  automargin=True),
                       yaxis=dict(title="Number of Genes",
                                  titlefont=dict(size=18, color='black'),
                                  showticklabels=True,
                                  tickfont=dict(size=10, color='black')))

    fig = go.Figure(data=data, layout=layout)
    offline.plot(fig, filename=outdir + "ngenes_boxplot.html", auto_open=False)

    return 
開發者ID:gtonkinhill,項目名稱:panaroo,代碼行數:57,代碼來源:generate_qc_plots.py

示例5: plot_ncontigs

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Box [as 別名]
def plot_ncontigs(input_gffs, outdir):

    # get simplified file names
    file_names = [
        os.path.splitext(os.path.basename(gff))[0] for gff in input_gffs
    ]

    # count genes
    ncontigs = np.zeros(len(input_gffs))
    for i, gff_file in enumerate(input_gffs):
        with open(gff_file, 'r') as gff:
            in_fasta = False
            for line in gff:
                if in_fasta and (line[0] == ">"):
                    ncontigs[i] += 1
                if "##FASTA" in line:
                    in_fasta = True

    # generate static plot
    with open(outdir + "ncontigs.txt", "w") as contig_out:
        contig_out.write("sample\tno_contigs\n")
        for i, j in zip(file_names, ncontigs):
            contig_out.write("%s\t%s\n" % (i, j))
    plt.style.use('ggplot')
    fig = plt.figure()
    plt.barh(np.arange(len(ncontigs)), ncontigs)
    plt.yticks(np.arange(len(ncontigs)), file_names)
    plt.grid(True)
    plt.ylabel("File Name")
    plt.xlabel("Number of Contigs")
    plt.tight_layout()
    fig.savefig(outdir + "ncontigs_barplot.png")

    # generate interactive boxplot
    data = [
        go.Box(y=ncontigs,
               text=file_names,
               hoverinfo="text",
               boxpoints='all',
               jitter=0.3,
               pointpos=-1.8)
    ]
    layout = go.Layout(autosize=True,
                       xaxis=dict(title='',
                                  titlefont=dict(size=18, color='black'),
                                  showticklabels=False,
                                  automargin=True),
                       yaxis=dict(title="Number of Contigs",
                                  titlefont=dict(size=18, color='black'),
                                  showticklabels=True,
                                  tickfont=dict(size=10, color='black')))

    fig = go.Figure(data=data, layout=layout)
    offline.plot(fig,
                 filename=outdir + "ncontigs_boxplot.html",
                 auto_open=False)

    return 
開發者ID:gtonkinhill,項目名稱:panaroo,代碼行數:60,代碼來源:generate_qc_plots.py

示例6: fig_boxplot_msglen

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Box [as 別名]
def fig_boxplot_msglen(df, username_to_color=None, title="", xlabel=None):
    """Visualize boxplot.

    Args:
        df (pandas.DataFrame): Chat data.
        username_to_color (dict, optional). Dictionary mapping username to color. Defaults to None.
        title (str, optional): Title for plot. Defaults to "".
        xlabel (str, optional): x-axis label title. Defaults to None.

    Returns:
        plotly.graph_objs.Figure

    """
    df = df.copy()
    # Get message lengths
    df[COLNAMES_DF.MESSAGE_LENGTH] = df[COLNAMES_DF.MESSAGE].apply(lambda x: len(x))
    # Sort users by median
    user_stats = df.groupby(COLNAMES_DF.USERNAME)\
        .aggregate({COLNAMES_DF.MESSAGE_LENGTH: 'median'})[COLNAMES_DF.MESSAGE_LENGTH].sort_values(ascending=False)

    # Create a list of traces
    data = []

    for username in user_stats.index:
        x = df[df[COLNAMES_DF.USERNAME] == username][COLNAMES_DF.MESSAGE_LENGTH]
        trace = go.Box(
            y=x.values,
            showlegend=True,
            name=username,
            boxpoints='outliers',
            marker_color=username_to_color[username] if username_to_color else None
        )
        data.append(trace)

    layout = dict(
        title=title,
        xaxis=dict(title=xlabel)
    )

    fig = go.Figure(data=data, layout=layout)

    return fig 
開發者ID:lucasrodes,項目名稱:whatstk,代碼行數:44,代碼來源:boxplot.py


注:本文中的plotly.graph_objs.Box方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。