How to use the plotly.graph_objs.Layout function in plotly

To help you get started, we’ve selected a few plotly examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vantaka2 / crypto_dash_app / app.py View on Github external
def scatter_plot(coin_select, datefilter):
    df = filter_reddit(df_scatter, coin_select, datefilter)
    data = [
        go.Scatter(
            y=df[df['name'] == i]['post_count'],
            x=df[df['name'] == i]['market_cap_usd'],
            opacity=0.8,
            hovertext=df[df['name'] == i]['created'],
            mode = 'markers',
            marker = dict(size = 15),
            name=i

        ) for i in coin_select
    ]
    layout = go.Layout(
        title='Mentions vs Marketcap',
        xaxis=dict(
             title='Marketcap (Log Scale)',
             
        type='log',
        autorange=True,
        
    ),
    hovermode='closest',
    yaxis=dict(
        title='Mention Count',
        
        autorange=True
    )
    )
    figure = {'data':data,
github Parsl / parsl / plots / default / workflow_plots.py View on Github external
x=[],
        y=[],
        line=dict(width=1, color='rgb(150,150,150)'),
        hoverinfo='none',
        showlegend=False,
        mode='lines')

    for edge in G.edges:
        x0, y0 = node_positions[edge[0]]
        x1, y1 = node_positions[edge[1]]
        edge_trace['x'] += tuple([x0, x1, None])
        edge_trace['y'] += tuple([y0, y1, None])

    # Create figure:
    fig = go.Figure(data = [edge_trace] + node_traces,
                 layout = go.Layout(
                    title = 'Workflow DAG',
                    titlefont = dict(size=16),
                    showlegend = True,
                    hovermode = 'closest',
                    margin = dict(b=20,l=5,r=5,t=40),
                    xaxis = dict(showgrid=False, zeroline=False, showticklabels=False),
                    yaxis = dict(showgrid=False, zeroline=False, showticklabels=False)))
    return plot(fig, show_link=False, output_type="div", include_plotlyjs=False)
github tiagofilipe12 / pATLAS / patlas / utils / node_size_n_links.py View on Github external
def make_histogram(trace_list):
    '''
    Function to make an histogram from a list
    Parameters
    ----------
    trace_list: list
        A list with all entries to the histogram (entries should be float)

    '''
    sorted_list = sorted(trace_list, reverse=True)
    trace_lengths = go.Histogram(x=sorted_list,
                                 opacity=0.75,
                                 name="Histogram of the size ratio between "
                                      "linked nodes")
    layout = go.Layout(barmode="overlay",
                           xaxis=dict(
                               title="number of links"
                           ),
                           yaxis=dict(
                               title="ratio between nodes"
                           )
                       )
    fig = go.Figure(data=[trace_lengths], layout=layout)
    plotly.offline.plot(fig, filename="dist.html", auto_open=False)
github LCAV / pyroomacoustics / pyroomacoustics / doa / plotters.py View on Github external
trace3 = go.Scatter3d(mode='markers', name='reconstruction',
                              x=x_recon, y=y_recon, z=z_recon,
                              text=text_str3,
                              hoverinfo='name+text',
                              marker=dict(size=6, symbol='diamond', opacity=0.6,
                                          line=dict(
                                              color='rgb(204, 204, 204)',
                                              width=2
                                          ),
                                          color='rgb(0.850, 0.325, 0.098)'))
        traces.append(trace3)

    data = go.Data(traces)

    layout = go.Layout(title='', autosize=False,
                       width=670, height=550, showlegend=True,
                       margin=go.Margin(l=45, r=45, b=55, t=45)
                       )

    layout['legend']['xanchor'] = 'center'
    layout['legend']['yanchor'] = 'top'
    layout['legend']['x'] = 0.5

    fig = go.Figure(data=data, layout=layout)
    plot(fig)
github tomleung1996 / wos_crawler / wos_crawler / analysis / draw / draw_cooccurrence_network.py View on Github external
line=dict(width=2)))

    for node in G.nodes():
        x, y = G.node[node]['pos']
        node_trace['x'] += tuple([x])
        node_trace['y'] += tuple([y])

    for node, adjacencies in enumerate(G.adjacency()):
        node_trace['marker']['color'] += tuple([len(adjacencies[1])])
        node_trace['textfont']['size'] += tuple([len(adjacencies[1]) * 5 + 1])
        node_info = adjacencies[0].title()
        node_trace['text'] += tuple([node_info])
        node_trace['marker']['size'] += tuple([len(adjacencies[1]) * 5])

    fig = go.Figure(data=[edge_trace, node_trace],
                    layout=go.Layout(
                        title='<br>' + title,
                        titlefont=dict(size=16),
                        showlegend=False,
                        hovermode='closest',
                        margin=dict(b=20, l=5, r=5, t=40),
                        # annotations=[dict(
                        #     text="Python code: <a href="https://plot.ly/ipython-notebooks/network-graphs/"> https://plot.ly/ipython-notebooks/network-graphs/</a>",
                        #     showarrow=False,
                        #     xref="paper", yref="paper",
                        #     x=0.005, y=-0.002)],
                        xaxis=dict(showgrid=False, zeroline=False, showticklabels=False),
                        yaxis=dict(showgrid=False, zeroline=False, showticklabels=False)))

    plotly.offline.plot(fig, filename='{}.html'.format(output_path), auto_open=False, image_width=1600,
                        image_height=900, image='png')
github BigRedT / vico / exp / cifar100 / vis / acc_vs_num_classes.py View on Github external
y.append(
                round(results[embed_type][num_held][metric_name],1))

        trace = go.Bar(
            x = [100-x_ for x_ in num_held_out_classes],
            y = y,
            text = y,
            textposition = 'auto',
            name = embed_type,
            marker = dict(color=embed_type_to_color[embed_type]),
            opacity=0.9,
        )
        traces.append(trace)

    xtitle = '#Trainable classes (= 100 - #Held out classes)'
    layout = go.Layout(
        #title = metric_name,
        xaxis = dict(title=xtitle),
        yaxis = dict(title=metric_name_to_ytitle[metric_name]),
        hovermode = 'closest',
        width=1000,
        height=600,
        barmode='group',
        bargap=0.15,
        bargroupgap=0.1)

    plotly.offline.plot(
        {'data': traces,'layout': layout},
        filename=filename,
        auto_open=False)
github kengz / SLM-Lab / slm_lab / lib / viz.py View on Github external
def create_layout(title, y_title, x_title, x_type=None, width=500, height=500, layout_kwargs=None):
    '''simplified method to generate Layout'''
    layout = go.Layout(
        title=title,
        legend=dict(x=0.0, y=-0.25, orientation='h'),
        yaxis=dict(rangemode='tozero', title=y_title),
        xaxis=dict(type=x_type, title=x_title),
        width=width, height=height,
        margin=go.layout.Margin(l=60, r=60, t=60, b=60),
    )
    layout.update(layout_kwargs)
    return layout
github Parsl / parsl / parsl / monitoring / web_app / plots / default / user_time.py View on Github external
task = df_resources[df_resources['task_id'] == app]['psutil_process_time_user'].astype('float').mean()
                elif option == 'max':
                    task = max(df_resources[df_resources['task_id'] == app]['psutil_process_time_user'].astype('float'))

                for i in range(len(x_axis) - 1):
                    a = task &gt;= x_axis[i]
                    b = task &lt; x_axis[i + 1]
                    tmp.append(a &amp; b)
                items = np.sum([items, tmp], axis=0)
            return items

        return go.Figure(
            data=[go.Bar(x=x_axis[:-1],
                         y=y_axis_setup(),
                         name='tasks')],
            layout=go.Layout(xaxis=dict(autorange=True,
                                        title='Duration (seconds)'),
                             yaxis=dict(title='Tasks'),
                             title='User Time Distribution'))
github pymzml / pymzML / example_scripts / spectrum_viewer.py View on Github external
title = 'Spectrum {0} @ RT: {1} [{2}s] of run {3}'.format(
        spectrum.ID,
        spectrum.scan_time[0],
        spectrum.scan_time[1],
        os.path.basename(sys.argv[1])
    )
    if spectrum.ms_level == 2:
        tmp_selected_precursors = spectrum.selected_precursors[0]
        format_str_template = '<br>'
        for key, format_template in [ ('mz',' Precursor m/z: {0}'), ('i', '; intensity {0:1.2e}'), ('charge','; charge: {0}') ]:
            if key in tmp_selected_precursors.keys():
                format_str_template += format_template.format(tmp_selected_precursors[key])
        title += format_str_template
    return {
        'data': [new_spectrum_plot],
        'layout': go.Layout(
            xaxis={ 'title': 'm/z'},
            yaxis={'title': 'Intensity',},
            margin={'l': 40, 'b': 40, 't': 80, 'r': 10},
            legend={'x': 0, 'y': 1},
            hovermode='closest',
            title = title
        )
github hrpan / tetris_mcts / web / web_dash.py View on Github external
layout=go.Layout(
        plot_bgcolor=colors['background'],
        paper_bgcolor=colors['background'],
        font={'color': colors['text']},
        height=700,
        width=300,
        xaxis=dict(visible=False),
        yaxis=dict(visible=False),
        margin=dict(l=5, t=5, b=5, r=5),
        hovermode=False
    ),
)

fig_weight = go.Figure(
    data=[],
    layout=go.Layout(
        title={'text': 'Weight Distribution',
               'font': {'color': colors['text']}},
        plot_bgcolor=colors['background'],
        paper_bgcolor=colors['background'],
        font={'color': colors['text']},
        height=400
    )
)

app.layout = html.Div([
            html.Div([
                dcc.Graph(id='live-ls', figure=fig),
                dcc.Graph(id='live-ls-50', figure=fig_50),
                dcc.Graph(id='live-ls-pt', figure=fig_pt),
                dcc.Graph(id='live-loss', figure=fig_loss),
                dcc.Graph(id='live-data', figure=fig_data),