How to use the plotly.offline 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 vincentzlt / textprep / draw.py View on Github external
y=share_token_rates,
        name='share token rates',
        mode='lines',
        yaxis='y2')

    layout = go.Layout(
        title='Shared tokens rates',
        xaxis=dict(title='bias', autorange=True),
        yaxis=dict(title='num of tokens', type='log', autorange=True),
        yaxis2=dict(
            title='accumlative share token rates',
            autorange=True,
            side='right',
            overlaying='y'))
    fig = go.Figure(data=[t1, t2], layout=layout)
    py.plot(
        fig, filename='{}_rate.html'.format(output_prefix), auto_open=False)
github metagenome-atlas / atlas / atlas / report / bin_report.py View on Github external
def main(samples, completeness_files, taxonomy_files, report_out, bin_table):
    sample_data = {}
    div = {}
    for sample in samples:
        sample_data[sample] = {}
        for completeness_file in completeness_files:
            # underscore version was for simplified local testing
            # if "%s_" % sample in completeness_file:
            if "%s/" % sample in completeness_file:
                sample_data[sample]["completeness"] = completeness_file
        for taxonomy_file in taxonomy_files:
            # if "%s_" % sample in taxonomy_file:
            if "%s/" % sample in taxonomy_file:
                sample_data[sample]["taxonomy"] = taxonomy_file
    df = parse_checkm_output(sample_data, bin_table)
    div["bin_scatter"] = offline.plot(
        {
            "data": [
                {
                    "x": df[df["Sample"] == sample]["Completeness"],
                    "y": df[df["Sample"] == sample]["Contamination"],
                    "name": sample,
                    "mode": "markers",
                    "text": df.index[df["Sample"] == sample],
                    "hoverinfo": "text",
                    "showlegend": True,
                }
                for sample in df.Sample.unique()
            ],
            "layout": {
                "xaxis": {"title": "Completeness"}, "yaxis": {"title": "Contamination"}
            },
github flask-dashboard / Flask-MonitoringDashboard / flask_monitoringdashboard / routings / result.py View on Github external
layout = go.Layout(
        autosize=True,
        height=350 + 40 * len(versions),
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=False,
        title='Execution time for every version',
        xaxis=dict(title='Execution time (ms)'),
        yaxis=dict(
            title='Version',
            autorange='reversed'
        ),
        margin=go.Margin(
            l=200
        )
    )
    return plotly.offline.plot(go.Figure(data=data, layout=layout), output_type='div', show_link=False)
github TOMToolkit / tom_base / tom_targets / templatetags / targets_extras.py View on Github external
'airmass': request.GET.get('airmass'),
            'target': context['object']
        })
        if plan_form.is_valid():
            start_time = parse(request.GET['start_time'])
            end_time = parse(request.GET['end_time'])
            if request.GET.get('airmass'):
                airmass_limit = float(request.GET.get('airmass'))
            else:
                airmass_limit = None
            visibility_data = get_sidereal_visibility(context['object'], start_time, end_time, 10, 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 {
        'form': plan_form,
        'target': context['object'],
        'visibility_graph': visibility_graph
    }
github fabiencro / knmt / nmt_chainer / utilities / graph_training.py View on Github external
yaxis=dict(
            title='loss',
            gridcolor='#bdbdbd'
        ),
        yaxis2=dict(
            title='bleu',
            overlaying='y',
            side='right'
        )
    )

    data = [trace0, trace1, trace2, trace3, trace4, trace0min, trace1max, trace2min, trace3max]
    #         data = [trace2, trace3, trace4, trace2min, trace3max]
    fig = go.Figure(data=data, layout=layout)
    # Plot and embed in ipython notebook!
    plotly.offline.plot(fig, filename=dest, auto_open=False)
github Chandlercjy / OnePy / OnePy / builtin_module / plotters / by_plotly.py View on Github external
total_holding_pnl = sum((i[i.columns[0]] for i in self.holding_pnl_df))
        total_holding_pnl = pd.DataFrame(total_holding_pnl)
        total_holding_pnl.columns = ['total_holding_pnl']
        self.append_trace(fig, total_holding_pnl, 2, 1)

        fig['layout']['yaxis'].update(
            dict(overlaying='y3', side='right', showgrid=False))
        # fig['layout']['xaxis']['type'] = 'category'
        # fig['layout']['xaxis']['rangeslider']['visible'] = False
        # fig['layout']['xaxis']['tickangle'] = 45
        fig['layout']['xaxis']['visible'] = False
        fig['layout']['hovermode'] = 'closest'
        fig['layout']['xaxis']['rangeslider']['visible'] = False

        if notebook:
            plotly.offline.init_notebook_mode()
            py.iplot(fig, filename='OnePy_plot.html', validate=False)
        else:
            py.plot(fig, filename='OnePy_plot.html', validate=False)
github shwang / pedestrian_prediction / study_traj.py View on Github external
grad, ex_1, ex_2 = _compute_gradient(g, traj, goal, beta=beta, debug=True)
        ex_1s.append(ex_1)
        ex_2s.append(ex_2)
        score = _compute_score(g, traj, goal, beta=beta)
        print "score={}: grad={}".format(score, grad)

    import plotly.offline as py
    import plotly.graph_objs as go
    ex_1s = np.array(ex_1s)
    ex_2s = np.array(ex_2s)
    diff = (ex_1s - ex_2s)
    data = []
    data.append(dict(x=betas, y=ex_1s))
    data.append(dict(x=betas, y=ex_2s))
    data.append(dict(x=betas, y=diff))
    py.plot(data, filename="output/grad_debug.html")
github ghtmtt / DataPlotly / DataPlotly / core / plot_factory.py View on Github external
elif grid == 'col':

            fig = tools.make_subplots(rows=row, cols=column)

            for i, itm in enumerate(ptrace):
                fig.append_trace(itm, i + 1, column)

        # set some configurations
        config = {'scrollZoom': True, 'editable': True}
        # first lines of additional html with the link to the local javascript
        self.raw_plot = '' \
                        ''.format(
            self.POLY_FILL_PATH, self.PLOTLY_PATH)
        # call the plot method without all the javascript code
        self.raw_plot += plotly.offline.plot(fig, output_type='div', include_plotlyjs=False, show_link=False,
                                             config=config)
        # insert callback for javascript events
        self.raw_plot += self.js_callback(self.raw_plot)

        # use regex to replace the string ReplaceTheDiv with the correct plot id generated by plotly
        match = re.search(r'Plotly.newPlot\(\s*[\'"](.+?)[\'"]', self.raw_plot)
        substr = match.group(1)
        self.raw_plot = self.raw_plot.replace('ReplaceTheDiv', substr)

        self.plot_path = os.path.join(tempfile.gettempdir(), 'temp_plot_name.html')
        with open(self.plot_path, "w") as f:
            f.write(self.raw_plot)

        return self.plot_path
github pik-copan / pycopancore / studies / run_adaptive_voter_model.py View on Github external
line=dict(
        color="red",
        width=2
    ),
    marker=dict(
        color="red",
        size=4
    )
)

layout = dict(title='Adaptive Voter Model',
              xaxis=dict(title='time'),
              )

fig = dict(data=[data_opinion0, data_opinion1, data_majority_opinion], layout=layout)
py.plot(fig, filename="adaptive-voter-model.html")