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


Python graph_objs.Layout方法代码示例

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


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

示例1: plotly_histogram

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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: create_label

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [as 别名]
def create_label(y_col, x_col, title=None, y_title=None, x_title=None, legend_name=None):
    '''Create label dict for go.Layout with smart resolution'''
    legend_name = legend_name or y_col
    y_col_list, x_col_list, legend_name_list = ps.map_(
        [y_col, x_col, legend_name], util.cast_list)
    y_title = str(y_title or ','.join(y_col_list))
    x_title = str(x_title or ','.join(x_col_list))
    title = title or f'{y_title} vs {x_title}'

    label = {
        'y_title': y_title,
        'x_title': x_title,
        'title': title,
        'y_col_list': y_col_list,
        'x_col_list': x_col_list,
        'legend_name_list': legend_name_list,
    }
    return label 
开发者ID:ConvLab,项目名称:ConvLab,代码行数:20,代码来源:viz.py

示例3: generate_chart

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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: make_layout

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [as 别名]
def make_layout(xkey, xscale, ykey, yscale):
    opts_dict = {
        'margin': {
            'l': 40,
            'b': 40,
            't': 10,
            'r': 10
        },
        'legend': {
            'x': 0,
            'y': 1
        },
        'hovermode': 'closest'
    }
    return go.Layout(xaxis={
        'type': xscale,
        'title': xkey
    },
                     yaxis={
                         'type': yscale,
                         'title': ykey
                     },
                     **opts_dict) 
开发者ID:negrinho,项目名称:deep_architect,代码行数:25,代码来源:main.py

示例5: observation_plan

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例6: _draw_scatter

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例7: test_generate_group_bar_charts

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例8: get_figure3d

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例9: heating_reset_schedule

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例10: peak_load_district

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例11: energy_use_intensity

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [as 别名]
def energy_use_intensity(data_frame, analysis_fields, title, output_path):
    # CREATE FIRST PAGE WITH TIMESERIES
    traces = []
    area = data_frame["GFA_m2"]
    x = ["Absolute [MWh/yr]", "Relative [kWh/m2.yr]"]
    for field in analysis_fields:
        name = NAMING[field]
        y = [data_frame[field], data_frame[field] / area * 1000]
        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', 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,代码行数:19,代码来源:energy_end_use_intensity.py

示例12: energy_use_intensity_district

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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

示例13: peak_load_building

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [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_supply.py

示例14: __init__

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [as 别名]
def __init__(self,visuals,datasource,**kwargs):
        Options.__init__(self,**kwargs)
        widgets.VBox.__init__(self,layout=widgets.Layout(width=self.getOpt("width","95%"),height=self.getOpt("height","95%"),border=visuals.getOpt("border","0"),padding=visuals.getOpt("padding","10px"),margin=visuals.getOpt("margin","10px")))
        self._visuals = visuals
        self._datasource = datasource
        self._figure = None
        self._data = None
        self._layout = None
        self._controls = None
        self._title = widgets.HTML(layout=widgets.Layout(overflow="hidden"))
        self._banner = widgets.VBox([self._title]) 
开发者ID:sassoftware,项目名称:python-esppy,代码行数:13,代码来源:visuals.py

示例15: create

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Layout [as 别名]
def create(self):
        self.createContent()

        if self._data != None:
            self._layout = go.Layout()

            margin = 20
            self._layout["margin"] = dict(l=margin,r=margin,b=margin,t=margin)

            xRange = self.getOpt("xrange")
            if xRange != None:
                self._layout["xaxis"]["range"] = xRange
            yRange = self.getOpt("yrange")
            if yRange != None:
                self._layout["yaxis"]["range"] = yRange

            self._layout["xaxis"]["showticklabels"] = self.getOpt("showticks",True)
            self._layout["xaxis"]["showline"] = False

            self._figure = go.FigureWidget(data=self._data,layout=self._layout)

            children = [self._banner,self._figure]

            if self.getOpt("show_controls",False):
                if self._controls == None:
                    self._controls = ControlPanel(self._datasource) 
                children.append(self._controls)

            self.children = children

        self.draw(None,True) 
开发者ID:sassoftware,项目名称:python-esppy,代码行数:33,代码来源:visuals.py


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