user8054212
user8054212

Reputation:

How to plot using plotly with offline mode out not in iPython notebooks?

I need to plot my data using plotly, But this code doesn't give me any result, I display my data, but without any figure:

    import plotly.graph_objs as go
    from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot

    data_t = []

    for mac, dico_data in dict_info.items():
        data_t.append(go.Scatter( x= dico_data['asn'], y= dico_data["time"], name=mac ))
        print (data_t)
    data = data_t
    iplot(data_t)

Upvotes: 6

Views: 8439

Answers (2)

BernardL
BernardL

Reputation: 5434

Try using:

init_notebook_mode(connected=True)

Or try using the inline mode in notebooks:

py.init_notebook_mode()

And if you are using it out of a notebook, try the following example:

import plotly
import plotly.graph_objs as go

plotly.offline.plot({
    "data": [go.Scatter(x=[1, 2, 3, 4], y=[4, 3, 2, 1])],
    "layout": go.Layout(title="hello world")
}, auto_open=True)

Read more in the plotly documentation: https://plot.ly/python/offline/

Upvotes: 7

DataFramed
DataFramed

Reputation: 1631

Issue: Due to inbuilt restriction in browser, you need to install

plotly-extension

Solution: Install it if missing with:

jupyter labextension install @jupyterlab/plotly-extension

Reference:

  1. https://jupyterlab.readthedocs.io/en/stable/user/extensions.html

Upvotes: 1

Related Questions