Plotly in Juypter Notebook On Kaggle

836 views Asked by At

I am trying to render a plotly graph in a Juypter Notebook (on Kaggle), and the code runs, but does not render an image. Using Plotly version 1.12.12, and Python 3.5. The output cell seems to just be hidden. Code for simple graph is below:

# Imports 
import plotly.plotly as py
import plotly.graph_objs as go
from plotly import tools
from plotly.offline import iplot, init_notebook_mode
init_notebook_mode(connected=True) 
# Graph
iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}])

I found some comments at the following link:

https://community.plot.ly/t/offline-mode-in-jupyter-notebook-shows-blank-graphs/1860/22

Still was not able to solve the issue. Any advice?

Thank You

2

There are 2 answers

2
Axis On

Your code looks like OK, here you are your code result.

enter image description here

First have you install plotly?

pip install plotly

Second try like this;

import plotly.plotly as py
import plotly.graph_objs as go
from plotly import tools
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True) 
# Graph
iplot([{"x": [1, 2, 3], "y": [3, 1, 6]}])
0
Jeff Saltfist On

The solution to this question is that the charts will not appear until hitting the publish button on Kaggle. Unlike Matplotlib, you can not view the plotly chart until you publish.