RainOver
RainOver

Reputation: 25

Jupyter notebook plotly not showing graph.. (just graph)

In jupyter notebook, My code do run.. just not showing graph.

I have tried many way..

My example code, picture.

My Code & picture

import plotly.offline as pyo
import plotly.graph_objs as go
pyo.init_notebook_mode()

trace0 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[5, 8, 2, 7]
)
trace1 = go.Scatter(
    x=[1, 2, 3, 4],
    y=[1, 5, 13, 2]
)
data = [trace0, trace1]
pyo.iplot(data, filename = 'ex')

enter image description here

And, I click a button; Download plot as png...

downloaded newplot.svg; open a file...

explorer

Capture newplot.svg

enter image description here

In new tap explorer, This graph show well.

why in jupyter notebook poltly not showing graph?

Just in case version. Add my python package version;

Upvotes: 3

Views: 18666

Answers (4)

Josh P
Josh P

Reputation: 1

If there's also not useful after install some packages, maybe you can try to restart the jupyter notebook, it works on to me:)

Upvotes: 0

Ksam
Ksam

Reputation: 11

# Import the necessaries libraries
import plotly.offline as pyo
import plotly.graph_objs as go
# Set notebook mode to work in offline
pyo.init_notebook_mode()
# Create traces
trace0 = go.Bar(
    x=[1, 2, 3, 4],
    y=[10, 15, 13, 17]
)
trace1 = go.Bar(
    x=[1, 2, 3, 4],
    y=[16, 5, 11, 9]
)
# Fill out data with our traces
data = [trace0, trace1]
# Plot it and save as basic-line.html
pyo.plot(data, filename = 'Test-bar.html', auto_open = False)

# Show HTML
from IPython.display import HTML
HTML(filename='Test-bar.html')

Upvotes: 0

Arun Kumar Khattri
Arun Kumar Khattri

Reputation: 1628

please refer to plotly's getting started documentation...

For use in the classic Jupyter Notebook, install the notebook and ipywidgets packages using pip...

$ pip install "notebook>=5.3" "ipywidgets>=7.2"

For use in JupyterLab, install the jupyterlab and ipywidgets packages using pip...

$ pip install jupyterlab "ipywidgets>=7.5"

Then run the following commands to install the required JupyterLab extensions (note that this will require node to be installed):

JupyterLab renderer support

jupyter labextension install [email protected]

OPTIONAL: Jupyter widgets extension

jupyter labextension install @jupyter-widgets/jupyterlab-manager [email protected]

Upvotes: 3

RainOver
RainOver

Reputation: 25

My method is Jupyter notebook Default program (Exploere -> Chrome)

Upvotes: -3

Related Questions