plotly.py: iplot doesn't display the graph at first in a new browser

hi, I use Plotly with Jupyter Notebook and it seems that the function to call ipilot in offline mode doesn’t always show the graph.

for example:

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

trace = go.Bar(x=[2, 4, 6], y= [10, 12, 15])
data = [trace]
layout = go.Layout(title='A Simple Plot', width=800, height=640)
fig = go.Figure(data=data, layout=layout)

plotly.offline.iplot(fig)

after accessing the Jupyter Notebook online, when I first go in the notebook with the preview’s code, it will not show the graph, I’ll need to refresh the tab of the notebook after some time to see it.

there is no error in the console nor anywhere.

plotly version : 1.12.0 python version : 3.4.3 IPython version : 4.2.0

Kevin.

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 25 (3 by maintainers)

Most upvoted comments

I change plotly version to 1.9.5 and the fig show again. I find “init_notebook_mode()” has no parameter at version 1.9.5. But has a default parameter at version 1.12.6.

save the notebook and refresh the brower

it works for me

Add before plot: %matplotlib inline

I’m facing to the same problem. On both Firefox 57.0.3 (64-bit) and Chromium 63.0.3239.108 (Developer Build) (64-bit). Python 3.6.4, Jupyter Notebook 5.0.0 and ipython-6.2.1-2. As @stuckeyr has mentioned, there are neither warnings nor errors. All I get is a white blank space in the output. Seems like the graphs are there but just hidden. It’s considerable that I’ve just installed plotly-2.2.3 which is the latest version.