Python plotly.graph_objects.Layout() Examples

The following are 5 code examples of plotly.graph_objects.Layout(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module plotly.graph_objects , or try the search function .
Example #1
Source File: tables.py    From arche with MIT License 6 votes vote down vote up
def score_table(quality_estimation, field_accuracy) -> go.FigureWidget:
    cells = [
        ["<b>Field Accuracy Score</b>", "<b>Overall Quality Score</b>"],
        ["<b>" + str(field_accuracy) + "<b>", "<b>" + str(quality_estimation) + "</b>"],
    ]

    font = dict(color="black", size=20)
    trace = go.Table(
        header=dict(
            values=[cells[0][0], cells[1][0]], fill=dict(color="gray"), font=font
        ),
        cells=dict(
            values=[cells[0][1:], cells[1][1:]],
            fill=dict(color=[[get_color(quality_estimation)]]),
            font=font,
        ),
    )

    layout = go.Layout(autosize=True, margin=dict(l=0, t=25, b=25, r=0), height=150)
    return go.FigureWidget(data=[trace], layout=layout) 
Example #2
Source File: view.py    From flaskerize with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def make_chart(title):
    import json

    import plotly.graph_objects as go
    import plotly

    layout = go.Layout(title=title)

    data = go.Scatter(
        x=[1, 2, 3, 4],
        y=[10, 11, 12, 13],
        mode="markers",
        marker=dict(size=[40, 60, 80, 100], color=[0, 1, 2, 3]),
    )

    fig = go.Figure(data=data)
    fig = json.dumps(fig, cls=plotly.utils.PlotlyJSONEncoder)
    layout = json.dumps(layout, cls=plotly.utils.PlotlyJSONEncoder)
    return fig, layout 
Example #3
Source File: Benchmarking Jupytext.py    From jupytext with MIT License 6 votes vote down vote up
def performance_plot(perf, title):
    formats = ['nbformat'] + JUPYTEXT_FORMATS
    mean = perf.groupby('implementation').mean().loc[formats]
    std = perf.groupby('implementation').std().loc[formats]
    data = [go.Bar(x=mean.index,
                   y=mean[col],
                   error_y=dict(
                       type='data',
                       array=std[col],
                       color=color,
                       thickness=0.5
                   ) if col != 'size' else dict(),
                   name=col,
                   yaxis={'read': 'y1', 'write': 'y2', 'size': 'y3'}[col])
            for col, color in zip(mean.columns, DEFAULT_PLOTLY_COLORS)]
    layout = go.Layout(title=title,
                       xaxis=dict(title='Implementation', anchor='y3'),
                       yaxis=dict(domain=[0.7, 1], title='Read (secs)'),
                       yaxis2=dict(domain=[0.35, .65], title='Write (secs)'),
                       yaxis3=dict(domain=[0, .3], title='Size')
                       )
    return go.Figure(data=data, layout=layout) 
Example #4
Source File: result.py    From arche with MIT License 5 votes vote down vote up
def get_layout(name: str, rows_count: int) -> go.Layout:
        return go.Layout(
            title=name,
            bargap=0.1,
            template="seaborn",
            height=min(max(rows_count * 20, 200), 900),
            hovermode="y",
            margin=dict(l=200, t=35),
        ) 
Example #5
Source File: tables.py    From arche with MIT License 4 votes vote down vote up
def coverage_by_categories(category_field, df, product_url_fields) -> go.FigureWidget:
    if category_field not in df.columns:
        return None
    if df[category_field].notnull().sum() == 0:
        return None

    cat_grouping = (
        df.groupby(category_field)[category_field]
        .count()
        .sort_values(ascending=False)
        .head(20)
    )
    category_values = cat_grouping.values
    category_names = cat_grouping.index

    if product_url_fields is not None and product_url_fields[0] in df.columns:
        product_url_field = product_url_fields[0]
        category_urls = [
            df[df[category_field] == cat][product_url_field].head(1).values[0]
            for cat in category_names
        ]
        href_tag = '<a href="{}">{}</a>'
        category_names = [
            href_tag.format(link, cat)
            for cat, link in zip(category_names, category_urls)
        ]

    trace = go.Table(
        columnorder=[1, 2],
        columnwidth=[400, 80],
        header=dict(
            values=[f"CATEGORY", "SCRAPED ITEMS"],
            fill=dict(color="gray"),
            align=["left"] * 5,
            font=dict(color="white", size=12),
            height=30,
        ),
        cells=dict(
            values=[category_names, category_values],
            fill=dict(color="lightgrey"),
            font=dict(color="black", size=12),
            height=30,
            align="left",
        ),
    )
    layout = go.Layout(
        title=f"Top 20 Categories for '{category_field}'",
        autosize=True,
        margin=dict(t=30, b=25, l=0, r=0),
        height=(len(category_names) + 2) * 45,
    )
    return go.FigureWidget(data=[trace], layout=layout)