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


Python graph_objs.Figure方法代码示例

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


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

示例1: plotly_histogram

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def plotly_histogram(array, color="#4CB391", title=None, xlabel=None, ylabel=None):
    data = [go.Histogram(x=array,
                         opacity=0.4,
                         marker=dict(color=color))]
    html = plotly.offline.plot(
        {"data": data,
         "layout": go.Layout(barmode='overlay',
                             title=title,
                             yaxis_title=ylabel,
                             xaxis_title=xlabel)},
        output_type="div",
        show_link=False)
    fig = go.Figure(
        {"data": data,
         "layout": go.Layout(barmode='overlay',
                             title=title)})
    return html, fig 
开发者ID:wdecoster,项目名称:NanoPlot,代码行数:19,代码来源:nanoplotter_main.py

示例2: plot_mean_sr

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def plot_mean_sr(sr_list, time_sr, title, y_title, x_title):
    '''Plot a list of series using its mean, with error bar using std'''
    mean_sr, std_sr = util.calc_srs_mean_std(sr_list)
    max_sr = mean_sr + std_sr
    min_sr = mean_sr - std_sr
    max_y = max_sr.tolist()
    min_y = min_sr.tolist()
    x = time_sr.tolist()
    color = get_palette(1)[0]
    main_trace = go.Scatter(
        x=x, y=mean_sr, mode='lines', showlegend=False,
        line={'color': color, 'width': 1},
    )
    envelope_trace = go.Scatter(
        x=x + x[::-1], y=max_y + min_y[::-1], showlegend=False,
        line={'color': 'rgba(0, 0, 0, 0)'},
        fill='tozerox', fillcolor=lower_opacity(color, 0.2),
    )
    data = [main_trace, envelope_trace]
    layout = create_layout(title=title, y_title=y_title, x_title=x_title)
    fig = go.Figure(data, layout)
    return fig 
开发者ID:ConvLab,项目名称:ConvLab,代码行数:24,代码来源:viz.py

示例3: generate_chart

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def generate_chart(self, _):
        try:
            import plotly
            import plotly.graph_objs as go
            data = [[0, 0, 0], [0, 0, 0]]
            ok, viol = self.results.get_ok_viol()
            x = ["OK (%d)" % ok, "Tampering (%d)" % viol]
            for ret in self.results:
                i = 1 if ret.is_tampering() else 0
                data[i][0] += ret.is_aligned()
                data[i][1] += ret.is_disaligned()
                data[i][2] += ret.is_single()
            final_data = [go.Bar(x=x, y=[x[0] for x in data], name="Aligned"), go.Bar(x=x, y=[x[1] for x in data], name="Disaligned"), go.Bar(x=x, y=[x[2] for x in data], name="Single")]
            fig = go.Figure(data=final_data, layout=go.Layout(barmode='group', title='Call stack tampering labels'))
            plotly.offline.plot(fig, output_type='file', include_plotlyjs=True, auto_open=True)
        except ImportError:
            self.log("ERROR", "Plotly module not available") 
开发者ID:RobinDavid,项目名称:idasec,代码行数:19,代码来源:callret_analysis.py

示例4: __init__

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def __init__(self, plotlyfig, colormap=None, pythonValue=None, **kwargs):
        '''
        Create a table object

        Parameters
        ----------
        plotlyfig : plotly.Figure
            The plotly figure to encapsulate

        colormap : ColorMap, optional
            A pygsti color map object used for this figure.

        pythonValue : object, optional
            A python object to be used as the Python-version of
            this figure (usually the data being plotted in some
            convenient format).

        kwargs : dict
            Additional meta-data relevant to this figure
        '''
        self.plotlyfig = plotlyfig
        self.colormap = colormap
        self.pythonvalue = pythonValue
        self.metadata = dict(kwargs).copy() 
开发者ID:pyGSTio,项目名称:pyGSTi,代码行数:26,代码来源:figure.py

示例5: draw_table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def draw_table(self, width=None, height=None, title=None, keep_ui_state=True, **kwargs):
        cols = self.main_data.data_df.index.names + self.main_data.data_df.columns.tolist()

        index1 = self.main_data.data_df.index.get_level_values(0).tolist()
        index2 = self.main_data.data_df.index.get_level_values(1).tolist()
        values = [index1] + [index2] + [self.main_data.data_df[col] for col in self.main_data.data_df.columns]

        data = go.Table(
            header=dict(values=cols,
                        fill_color=['#000080', '#000080'] + ['#0066cc'] * len(self.main_data.data_df.columns),
                        align='left',
                        font=dict(color='white', size=13)),
            cells=dict(values=values, fill=dict(color='#F5F8FF'), align='left'), **kwargs)

        fig = go.Figure()
        fig.add_traces([data])
        fig.update_layout(self.gen_plotly_layout(width=width, height=height, title=title, keep_ui_state=keep_ui_state))

        fig.show() 
开发者ID:zvtvz,项目名称:zvt,代码行数:21,代码来源:drawer.py

示例6: custom_plot

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def custom_plot(data: Any, layout: Any, return_figure=True) -> "plotly.Figure":
    """A custom plotly plot where the data and layout are pre-specified

    Parameters
    ----------
    data : Any
        Plotly data block
    layout : Any
        Plotly layout block
    return_figure : bool, optional
        Returns the raw plotly figure or not
    """

    check_plotly()
    import plotly.graph_objs as go

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

    return _configure_return(figure, "qcportal-bar", return_figure) 
开发者ID:MolSSI,项目名称:QCPortal,代码行数:21,代码来源:visualization.py

示例7: observation_plan

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def observation_plan(target, facility, length=7, interval=60, airmass_limit=None):
    """
    Displays form and renders plot for visibility calculation. Using this templatetag to render a plot requires that
    the context of the parent view have values for start_time, end_time, and airmass.
    """

    visibility_graph = ''
    start_time = datetime.now()
    end_time = start_time + timedelta(days=length)

    visibility_data = get_sidereal_visibility(target, start_time, end_time, interval, airmass_limit)
    plot_data = [
        go.Scatter(x=data[0], y=data[1], mode='lines', name=site) for site, data in visibility_data.items()
    ]
    layout = go.Layout(yaxis=dict(autorange='reversed'))
    visibility_graph = offline.plot(
        go.Figure(data=plot_data, layout=layout), output_type='div', show_link=False
    )

    return {
        'visibility_graph': visibility_graph
    } 
开发者ID:TOMToolkit,项目名称:tom_base,代码行数:24,代码来源:observation_extras.py

示例8: _draw_scatter

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def _draw_scatter(all_vocabs, all_freqs, output_prefix):
    colors = [(s and t) and (s < t and s / t or t / s) or 0
              for s, t in all_freqs]
    colors = [c and np.log(c) or 0 for c in colors]
    trace = go.Scattergl(
        x=[s for s, t in all_freqs],
        y=[t for s, t in all_freqs],
        mode='markers',
        text=all_vocabs,
        marker=dict(color=colors, showscale=True, colorscale='Viridis'))
    layout = go.Layout(
        title='Scatter plot of shared tokens',
        hovermode='closest',
        xaxis=dict(title='src freq', type='log', autorange=True),
        yaxis=dict(title='trg freq', type='log', autorange=True))

    fig = go.Figure(data=[trace], layout=layout)
    py.plot(
        fig, filename='{}_scatter.html'.format(output_prefix), auto_open=False) 
开发者ID:vincentzlt,项目名称:textprep,代码行数:21,代码来源:draw.py

示例9: test_generate_group_bar_charts

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def test_generate_group_bar_charts(self, mock_py):
        x_values = [
            [5.10114882, 5.0194652482, 4.9908093076],
            [4.5824497358, 4.7083614037, 4.3812775722],
            [2.6839471308, 3.0441476209, 3.6403820447]
        ]
        y_values = ['#kubuntu-devel', '#ubuntu-devel', '#kubuntu']
        trace_headers = ['head1', 'head2', 'head3']
        test_data = [
            go.Bar(
                x=x_values,
                y=y_values[i],
                name=trace_headers[i]
            ) for i in range(len(y_values))
        ]

        layout = go.Layout(barmode='group')
        fig = go.Figure(data=test_data, layout=layout)
        vis.generate_group_bar_charts(y_values, x_values, trace_headers, self.test_data_dir, 'test_group_bar_chart')
        self.assertEqual(mock_py.call_count, 1)
        self.assertEqual(fig.get('data')[0], mock_py.call_args[0][0].get('data')[0]) 
开发者ID:prasadtalasila,项目名称:IRCLogParser,代码行数:23,代码来源:test_vis.py

示例10: get_figure3d

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def get_figure3d(points3d, gt=None, range_scale=1):
    """Yields plotly fig for visualization"""
    traces = get_trace3d(points3d, BLUE, BLUE, "prediction")
    if gt is not None:
        traces += get_trace3d(gt, RED, RED, "groundtruth")
    layout = go.Layout(
        scene=dict(
            aspectratio=dict(x=0.8,
                             y=0.8,
                             z=2),
            xaxis=dict(range=(-0.4 * range_scale, 0.4 * range_scale),),
            yaxis=dict(range=(-0.4 * range_scale, 0.4 * range_scale),),
            zaxis=dict(range=(-1 * range_scale, 1 * range_scale),),),
        width=700,
        margin=dict(r=20, l=10, b=10, t=10))
    return go.Figure(data=traces, layout=layout) 
开发者ID:kongchen1992,项目名称:deep-nrsfm,代码行数:18,代码来源:motion_capture.py

示例11: heating_reset_schedule

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def heating_reset_schedule(data_frame, analysis_fields, title, output_path):
    # CREATE FIRST PAGE WITH TIMESERIES
    traces = []
    x = data_frame["T_ext_C"].values
    data_frame = data_frame.replace(0, np.nan)
    for field in analysis_fields:
        y = data_frame[field].values
        name = NAMING[field]
        trace = go.Scattergl(x=x, y=y, name=name, mode='markers',
                           marker=dict(color=COLOR[field]))
        traces.append(trace)

    layout = go.Layout(images=LOGO, title=title,
                       xaxis=dict(title='Outdoor Temperature [C]'),
                       yaxis=dict(title='HVAC System Temperature [C]'))
    fig = go.Figure(data=traces, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:21,代码来源:heating_reset_schedule.py

示例12: peak_load_building

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def peak_load_building(data_frame, analysis_fields, title, output_path):
    # CREATE FIRST PAGE WITH TIMESERIES
    traces = []
    area = data_frame["GFA_m2"]
    data_frame = data_frame[analysis_fields]
    x = ["Absolute [kW] ", "Relative [W/m2]"]
    for field in analysis_fields:
        y = [data_frame[field], data_frame[field] / area * 1000]
        name = NAMING[field]
        trace = go.Bar(x=x, y=y, name=name,
                       marker=dict(color=COLOR[field]))
        traces.append(trace)

    layout = go.Layout(images=LOGO, title=title, barmode='group', yaxis=dict(title='Peak Load'), showlegend=True)
    fig = go.Figure(data=traces, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:20,代码来源:peak_load.py

示例13: peak_load_district

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def peak_load_district(data_frame_totals, analysis_fields, title, output_path):
    traces = []
    data_frame_totals['total'] = data_frame_totals[analysis_fields].sum(axis=1)
    data_frame_totals = data_frame_totals.sort_values(by='total',
                                                      ascending=False)  # this will get the maximum value to the left
    for field in analysis_fields:
        y = data_frame_totals[field]
        total_perc = (y / data_frame_totals['total'] * 100).round(2).values
        total_perc_txt = ["(" + str(x) + " %)" for x in total_perc]
        name = NAMING[field]
        trace = go.Bar(x=data_frame_totals["Name"], y=y, name=name,
                       marker=dict(color=COLOR[field]))
        traces.append(trace)

    layout = go.Layout(title=title, barmode='group', yaxis=dict(title='Peak Load [kW]'), showlegend=True)
    fig = go.Figure(data=traces, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:21,代码来源:peak_load.py

示例14: energy_use_intensity_district

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def energy_use_intensity_district(data_frame, analysis_fields, title, output_path):
    traces = []
    data_frame_copy = data_frame.copy()  # make a copy to avoid passing new data of the dataframe around the class
    for field in analysis_fields:
        data_frame_copy[field] = data_frame_copy[field] * 1000 / data_frame_copy["GFA_m2"]  # in kWh/m2y
        data_frame_copy['total'] = data_frame_copy[analysis_fields].sum(axis=1)
        data_frame_copy = data_frame_copy.sort_values(by='total',
                                                      ascending=False)  # this will get the maximum value to the left
    x = data_frame_copy["Name"].tolist()
    for field in analysis_fields:
        y = data_frame_copy[field]
        name = NAMING[field]
        trace = go.Bar(x=x, y=y, name=name, marker=dict(color=COLOR[field]))
        traces.append(trace)

    layout = go.Layout(images=LOGO, title=title, barmode='stack', yaxis=dict(title='Energy Use Intensity [kWh/m2.yr]'),
                       showlegend=True)
    fig = go.Figure(data=traces, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:23,代码来源:energy_end_use_intensity.py

示例15: load_duration_curve

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Figure [as 别名]
def load_duration_curve(data_frame, analysis_fields, title, output_path):
    # CALCULATE GRAPH
    traces_graph = calc_graph(analysis_fields, data_frame)

    # CALCULATE TABLE
    traces_table = calc_table(analysis_fields, data_frame)

    # PLOT GRAPH

    traces_graph.append(traces_table)
    layout = go.Layout(images=LOGO, title=title, xaxis=dict(title='Duration Normalized [%]', domain=[0, 1]),
                       yaxis=dict(title='Load [kW]', domain=[0.0, 0.7]), showlegend=True)
    fig = go.Figure(data=traces_graph, layout=layout)
    plot(fig, auto_open=False, filename=output_path)

    return {'data': traces_graph, 'layout': layout} 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:18,代码来源:load_duration_curve.py


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