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


Python graph_objs.Table方法代码示例

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


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

示例1: draw_table

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

示例2: calc_table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def calc_table(analysis_fields, data_frame):
    # calculate variables for the analysis
    loss_peak = data_frame[analysis_fields].max().round(2).tolist()  # save maximum value of loss
    loss_total = (data_frame[analysis_fields].sum() / 1000).round(2).tolist()  # save total loss value

    # calculate graph
    load_utilization = []
    loss_names = []
    # data = ''
    duration = range(HOURS_IN_YEAR)
    x = [(a - min(duration)) / (max(duration) - min(duration)) * 100 for a in duration]
    for field in analysis_fields:
        field_1 = field.split('_')[0]
        field_2 = field.split('_')[1]
        field_3 = field_1 + '_' + field_2
        data_frame_new = data_frame.sort_values(by=field, ascending=False)
        y = data_frame_new[field].values
        load_utilization.append(evaluate_utilization(x, y))
        loss_names.append(NAMING[field] + ' (' + field_3 + ')')
    table = go.Table(domain=dict(x=[0, 1], y=[0.7, 1.0]),
                     header=dict(
                         values=['Name', 'Peak Load [kW]', 'Yearly Demand [MWh]', 'Utilization [-]']),
                     cells=dict(values=[loss_names, loss_peak, loss_total, load_utilization]))
    return table 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:26,代码来源:f_pump_duration_curve.py

示例3: calc_table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def calc_table(analysis_fields, data_frame):
    # calculate variables for the analysis
    load_peak = data_frame[analysis_fields].max().round(2).tolist()
    load_total = (data_frame[analysis_fields].sum() / 1000).round(2).tolist()

    # calculate graph
    load_utilization = []
    load_names = []
    # data = ''
    duration = range(HOURS_IN_YEAR)
    x = [(a - min(duration)) / (max(duration) - min(duration)) * 100 for a in duration]
    for field in analysis_fields:
        data_frame_new = data_frame.sort_values(by=field, ascending=False)
        y = data_frame_new[field].values
        load_utilization.append(evaluate_utilization(x, y))
        load_names.append(NAMING[field] + ' (' + field.split('_', 1)[0] + ')')
    table = go.Table(domain=dict(x=[0, 1], y=[0.7, 1.0]),
                     header=dict(
                         values=['Load Name', 'Peak Load [kW]', 'Yearly Demand [MWh]', 'Utilization [-]']),
                     cells=dict(values=[load_names, load_peak, load_total, load_utilization]))
    return table 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:23,代码来源:load_duration_curve.py

示例4: calc_table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def calc_table(analysis_fields, data_frame):
    median = data_frame[analysis_fields].median().round(2).tolist()
    total = data_frame[analysis_fields].sum().round(2).tolist()
    total_perc = [str(x) + " (" + str(round(x / sum(total) * 100, 1)) + " %)" for x in total]
    # calculate graph
    anchors = []
    load_names = []
    for field in analysis_fields:
        anchors.append(calc_top_three_anchor_loads(data_frame, field))
        load_names.append(NAMING[field] + ' (' + field.split('_', 1)[0] + ')')

    table = go.Table(domain=dict(x=[0, 1.0], y=[0, 0.2]),
                     header=dict(values=['Load Name', 'Total [MWh/yr]', 'Median [MWh/yr]', 'Top 3 Consumers']),
                     cells=dict(values=[load_names, total_perc, median, anchors]))

    return table 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:18,代码来源:energy_end_use.py

示例5: calc_table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def calc_table(data_frame_month):
    """
    draws table of monthly energy balance

    :param data_frame_month: data frame of monthly building energy balance
    :return:
    """

    # create table arrays
    name_month = np.append(data_frame_month.index, ['YEAR'])
    total_heat = np.append(data_frame_month['Q_heat_sum'].values, data_frame_month['Q_heat_sum'].sum())
    total_cool = np.append(data_frame_month['Q_cool_sum'], data_frame_month['Q_cool_sum'].sum())
    balance = np.append(data_frame_month['Q_balance'], data_frame_month['Q_balance'].sum().round(2))

    # draw table
    table = go.Table(domain=dict(x=[0, 1], y=[0.0, 0.2]),
                     header=dict(values=['Month', 'Total heat [kWh/m2_GFA]', 'Total cool [kWh/m2_GFA]',
                                         'Delta [kWh/m2_GFA]']),
                     cells=dict(values=[name_month, total_heat, total_cool, balance]))

    return table 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:23,代码来源:energy_balance.py

示例6: _table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def _table(self, node):
        p = None if node.p is None else format(node.p, ".5f")
        score = None if node.score is None else format(node.score, ".2f")
        values = [p, score, node.split.column]
        return go.Table(
            cells=dict(values=[TABLE_HEADER, values], **TABLE_CELLS_CONFIG),
            **TABLE_CONFIG
        ) 
开发者ID:Rambatino,项目名称:CHAID,代码行数:10,代码来源:graph.py

示例7: calc_table

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def calc_table(dict_graph):
    """
    draws table of monthly energy balance

    :param dict_graph: dict containing the lists of summer, winter, occupied and unoccupied operative temperatures and
     \moisture ratios, i.e. the results of comfort_chart.calc_data
    :type dict_graph: dict
    :return: plotly table trace
    :rtype: plotly.graph_objs.Table
    """

    # create table arrays
    # check winter comfort
    count_winter_comfort, count_winter_uncomfort = check_comfort(dict_graph['t_op_occupied_winter'],
                                                                 dict_graph['x_int_occupied_winter'],
                                                                 VERTICES_WINTER_COMFORT)
    winter_hours = len(dict_graph['t_op_occupied_winter'])
    perc_winter_comfort = count_winter_comfort/winter_hours if winter_hours > 0 else 0
    cell_winter_comfort = "{} ({:.0%})".format(count_winter_comfort, perc_winter_comfort)
    perc_winter_uncomfort = count_winter_uncomfort / winter_hours if winter_hours > 0 else 0
    cell_winter_uncomfort = "{} ({:.0%})".format(count_winter_uncomfort, perc_winter_uncomfort)

    # check summer comfort
    count_summer_comfort, count_summer_uncomfort = check_comfort(dict_graph['t_op_occupied_summer'],
                                                                 dict_graph['x_int_occupied_summer'],
                                                                 VERTICES_SUMMER_COMFORT)
    summer_hours = len(dict_graph['t_op_occupied_summer'])
    perc_summer_comfort = count_summer_comfort / summer_hours if summer_hours > 0 else 0
    cell_summer_comfort = "{} ({:.0%})".format(count_summer_comfort, perc_summer_comfort)
    perc_summer_uncomfort = count_summer_uncomfort / summer_hours if summer_hours > 0 else 0
    cell_summer_uncomfort = "{} ({:.0%})".format(count_summer_uncomfort, perc_summer_uncomfort)

    # draw table
    table = go.Table(domain=dict(x=[0.0, 1], y=[YAXIS_DOMAIN_GRAPH[1], 1.0]),
                     header=dict(values=['condition', 'comfort [h]', 'uncomfort [h]']),
                     cells=dict(values=[['summer occupied', 'winter occupied'],
                                        [cell_summer_comfort, cell_winter_comfort],
                                        [cell_summer_uncomfort, cell_winter_uncomfort]]),
                     visible=True)

    return table 
开发者ID:architecture-building-systems,项目名称:CityEnergyAnalyst,代码行数:43,代码来源:comfort_chart.py

示例8: __summary_plot

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def __summary_plot (self, width, height, plot_title, header, data_format, data):
        """Private function generating summary table plots"""
        self.logger.info ("\t\tComputing plot")

        # Plot data
        data = [go.Table(
            header = {
                "values":header,
                "align":"center", "fill":{"color":"grey"},
                "font":{"size":14, "color":"white"},
                "height":40},
            cells = {
                "values":data,
                "format": data_format,
                "align":"center",
                "fill":{"color":"whitesmoke"},
                "font":{"size":12}, "height":30})]

        # tweak plot layout
        layout = go.Layout (
            width = width,
            height = height,
            title = {"text":plot_title, "xref":"paper" ,"x":0.5, "xanchor":"center"})

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

    #~~~~~~~1D DISTRIBUTION METHODS AND HELPER~~~~~~~# 
开发者ID:a-slide,项目名称:pycoQC,代码行数:29,代码来源:pycoQC_plot.py

示例9: alignment_reads_status

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def alignment_reads_status (self,
        colors:list=["#f44f39","#fc8161","#fcaf94","#828282"],
        width:int= None,
        height:int=500,
        plot_title:str="Summary of reads alignment status"):
        """
        Plot a basic alignment summary
        * colors
            List of colors (hex, rgb, rgba, hsl, hsv or any CSS named colors https://www.w3.org/TR/css-color-3/#svg-color
        * width
            With of the plotting area in pixel
        * height
            height of the plotting area in pixel
        * plot_title
            Title to display on top of the plot
        """
        # Verify that alignemnt information are available
        if not self.has_alignment:
            raise pycoQCError ("No Alignment information available")
        self.logger.info ("\t\tComputing plot")

        df = self.alignments_df
        # Create empty multiplot figure
        fig = make_subplots(rows=1, cols=2, column_widths=[0.4, 0.6], specs=[[{"type": "table"},{"type": "pie"}]])

        # plot Table
        data = go.Table(
            columnwidth = [3,2,2],
            header = {"values":list(df.columns), "align":"center", "fill_color":"grey", "font_size":14, "font_color":"white", "height":40},
            cells = {"values":df.values.T , "align":"center", "fill_color":"whitesmoke", "font_size":12, "height":30})
        fig.add_trace (data, row=1, col=1)

        # plot Pie plot
        data = go.Pie (
            labels=df["Alignments"],
            values=df["Counts"],
            sort=False,
            marker={"colors":colors},
            name="Pie plot",
            textinfo='label+percent')
        fig.add_trace (data, row=1, col=2)

        # Change the layout
        fig.update_layout(
            width = width,
            height = height,
            title = {"text":plot_title, "xref":"paper" ,"x":0.5, "xanchor":"center"})

        return fig

    #~~~~~~~ALIGNMENT RATE METHOD AND HELPER~~~~~~~# 
开发者ID:a-slide,项目名称:pycoQC,代码行数:53,代码来源:pycoQC_plot.py

示例10: ipy_plot_interactive

# 需要导入模块: from plotly import graph_objs [as 别名]
# 或者: from plotly.graph_objs import Table [as 别名]
def ipy_plot_interactive(df, opacity=.3):
    import plotly.graph_objs as go
    from ipywidgets import interactive
    if 'labels' in df.columns:
        text = [f'Class {k}: index {i}' for i,k in zip(df.index, df.labels)] # hovertext
    else:
        text = [f'index {i}' for i in df.index] # hovertext
    
    xaxis, yaxis = df.columns[0], df.columns[1]
    f = go.FigureWidget([go.Scattergl(x=df[xaxis],
                                  y=df[yaxis],
                                  mode='markers',
                                  text=text,
                                  marker=dict(size=2,
                                              opacity=opacity,
                                              color=np.arange(len(df)),
                                              colorscale='hsv'
                                             ))])
    scatter = f.data[0]
    N = len(df)
    f.update_layout(xaxis_title=xaxis, yaxis_title=yaxis)
    f.layout.dragmode = 'lasso'

    def update_axes(xaxis, yaxis, color_by, colorscale):
        scatter = f.data[0]
        scatter.x = df[xaxis]
        scatter.y = df[yaxis]
        
        scatter.marker.colorscale = colorscale
        if colorscale is None:
            scatter.marker.color = None
        else:
            scatter.marker.color = df[color_by] if color_by != 'index' else df.index
        with f.batch_update(): # what is this for??
            f.layout.xaxis.title = xaxis
            f.layout.yaxis.title = yaxis
 
    widget = interactive(update_axes, 
                         yaxis=df.select_dtypes('number').columns, 
                         xaxis=df.select_dtypes('number').columns,
                         color_by = df.columns,
                         colorscale = [None,'hsv','plotly3','deep','portland','picnic','armyrose'])

    t = go.FigureWidget([go.Table(
                        header=dict(values=['index']),
                        cells=dict(values=[df.index]),
                        )])

    def selection_fn(trace, points, selector):
        t.data[0].cells.values = [df.loc[points.point_inds].index]

    scatter.on_selection(selection_fn)
    return widget, f, t 
开发者ID:zhonge,项目名称:cryodrgn,代码行数:55,代码来源:analysis.py


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