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


Python graph_objs.Bar方法代碼示例

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


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

示例1: generate_chart

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [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

示例2: createContent

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [as 別名]
def createContent(self):
        values = self.getValues("y")
        colors = self._visuals._colors.getFirst(len(values))
        opacity = self.getOpt("opacity")

        self._data = []

        orientation = self.getOpt("orientation","vertical")

        if orientation == "horizontal":
            for i,v in enumerate(values):
                self._data.append(go.Bar(x=[0],y=[""],name=v,orientation="h",marker_color=colors[i]))

        else:
            for i,v in enumerate(values):
                self._data.append(go.Bar(x=[""],y=[0],name=v,opacity=opacity,marker_color=colors[i])) 
開發者ID:sassoftware,項目名稱:python-esppy,代碼行數:18,代碼來源:visuals.py

示例3: test_generate_group_bar_charts

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [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

示例4: calc_graph

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

        # data about demand
        for field in self.analysis_field_demand:
            y = (data[field].values) / 1E6  # into MW
            trace = go.Scattergl(x=data.index, y=y, name=NAMING[field],
                                 line=dict(width=1, color=COLOR[field]))

            graph.append(trace)

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

示例5: calc_graph

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

        # data about demand
        for field in self.analysis_field_demand:
            y = (data[field].values) / 1E6  # into MW
            trace = go.Scattergl(x=data.index, y=y, name=NAMING[field],
                               line=dict(width=1, color=COLOR[field]))

            graph.append(trace)

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

示例6: calc_graph

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

        # data about demand
        for field in self.analysis_field_demand:
            y = (data[field].values) / 1E6  # into MWh
            trace = go.Scattergl(x=data.index, y=y, name=NAMING[field],
                               line=dict(width=1, color=COLOR[field]))

            graph.append(trace)

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

示例7: calc_graph

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [as 別名]
def calc_graph(self):
        # calculate graph
        graph = []
        # format demand values
        P_loss_kWh = self.P_loss_kWh.fillna(value=0)
        P_loss_kWh = pd.DataFrame(P_loss_kWh.sum(axis=0), columns=['P_loss_kWh'])
        Q_loss_kWh = abs(self.thermal_loss_edges_kWh.fillna(value=0))
        Q_loss_kWh = pd.DataFrame(Q_loss_kWh.sum(axis=0), columns=['Q_loss_kWh'])
        # calculate total_df
        total_df = pd.DataFrame(P_loss_kWh.values + Q_loss_kWh.values, index=Q_loss_kWh.index, columns=['total'])
        # join dataframes
        merged_df = P_loss_kWh.join(Q_loss_kWh).join(total_df)
        merged_df = merged_df.sort_values(by='total',
                                          ascending=False)  # this will get the maximum value to the left

        # iterate through P_loss_kWh to plot
        for field in ['P_loss_kWh', 'Q_loss_kWh']:
            total_percent = (merged_df[field] / merged_df['total'] * 100).round(2)
            total_percent_txt = ["(" + str(x) + " %)" for x in total_percent]
            trace = go.Bar(x=merged_df.index, y=merged_df[field].values, name=NAMING[field],
                           text=total_percent_txt,
                           orientation='v',
                           marker=dict(color=COLOR[field]))
            graph.append(trace)
        return graph 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:27,代碼來源:d_energy_loss_bar.py

示例8: calc_graph

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [as 別名]
def calc_graph(self):
        data = self.calculate_hourly_loads()
        traces = []
        analysis_fields = self.remove_unused_fields(data, self.analysis_fields)
        for field in analysis_fields:
            y = data[field].values / 1E3  # to MW
            name = NAMING[field]
            trace = go.Bar(x=data.index, y=y, name=name, marker=dict(color=COLOR[field]))
            traces.append(trace)

        data_T = self.calculate_external_temperature()
        for field in ["T_ext_C"]:
            y = data_T[field].values
            name = NAMING[field]
            trace = go.Scattergl(x=data_T.index, y=y, name=name, yaxis='y2', opacity=0.2)
            traces.append(trace)
        return traces 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:19,代碼來源:load_curve.py

示例9: calc_graph

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [as 別名]
def calc_graph(self):
        analysis_fields = self.remove_unused_fields(self.data, self.analysis_fields)
        if len(self.buildings) == 1:
            assert len(self.data) == 1, 'Expected DataFrame with only one row'
            building_data = self.data.iloc[0]
            traces = []
            area = building_data["GFA_m2"]
            x = ["Absolute [kW]", "Relative [W/m2]"]
            for field in analysis_fields:
                name = NAMING[field]
                y = [building_data[field], building_data[field] / area * 1000]
                trace = go.Bar(x=x, y=y, name=name, marker=dict(color=COLOR[field]))
                traces.append(trace)
            return traces
        else:
            traces = []
            dataframe = self.data
            for field in analysis_fields:
                y = dataframe[field]
                name = NAMING[field]
                trace = go.Bar(x=dataframe["Name"], y=y, name=name, marker=dict(color=COLOR[field]))
                traces.append(trace)
            return traces 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:25,代碼來源:peak_load.py

示例10: peak_load_building

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [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

示例11: peak_load_district

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [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

示例12: energy_use_intensity

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [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

示例13: energy_use_intensity_district

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [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

示例14: calc_graph

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [as 別名]
def calc_graph(self):
        analysis_fields = self.remove_unused_fields(self.data, self.analysis_fields)
        if len(self.buildings) == 1:
            assert len(self.data) == 1, 'Expected DataFrame with only one row'
            building_data = self.data.iloc[0]
            traces = []
            area = building_data["GFA_m2"]
            x = ["Absolute [kW]", "Relative [kW/m2]"]
            for field in analysis_fields:
                name = NAMING[field]
                y = [building_data[field], building_data[field] / area * 1000]
                trace = go.Bar(x=x, y=y, name=name, marker=dict(color=COLOR[field]))
                traces.append(trace)
            return traces
        else:
            traces = []
            dataframe = self.data
            for field in analysis_fields:
                y = dataframe[field]
                name = NAMING[field]
                trace = go.Bar(x=dataframe["Name"], y=y, name=name, marker=dict(color=COLOR[field]))
                traces.append(trace)
            return traces 
開發者ID:architecture-building-systems,項目名稱:CityEnergyAnalyst,代碼行數:25,代碼來源:peak_load_supply.py

示例15: calc_graph

# 需要導入模塊: from plotly import graph_objs [as 別名]
# 或者: from plotly.graph_objs import Bar [as 別名]
def calc_graph(self):
        graph = []
        analysis_fields = self.remove_unused_fields(self.data, self.analysis_fields)
        dataframe = self.data
        dataframe['total'] = dataframe[analysis_fields].sum(axis=1)
        dataframe.sort_values(by='total', ascending=False, inplace=True)
        dataframe.reset_index(inplace=True, drop=True)
        for field in analysis_fields:
            y = dataframe[field]
            name = NAMING[field]
            total_percent = (y / dataframe['total'] * 100).round(2).values
            total_percent_txt = ["(%.2f %%)" % x for x in total_percent]
            trace = go.Bar(x=dataframe["Name"], y=y, name=name, text=total_percent_txt, orientation='v',
                           marker=dict(color=COLOR[field]))
            graph.append(trace)

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


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