Offline Mode in Jupyter Notebook shows blank graphs

I’m having some trouble using plotly in offline mode from within Jupyter notebook. First, my sample code:

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

# Make plotly work with Jupyter notebook
init_notebook_mode()

keys=['one','two','three']
values=[1,2,3]

iplot({
    "data": [go.Bar(x=keys, y=values)],
    "layout": go.Layout(title="Sample Bar Chart")
})

When I run this, I get no errors. The cell expands to include size for the graph, but it’s just blank white space with no bars, axes, labels or anything. When I adapt the same code to online mode or offline with output to a file, it all works as expected. Is there something I’m doing wrong, or just an issue with compatibility with the latest version of Jupyter?

1 Like

Hi there,

So I ran your code in my notebook and there were no problems. The graph showed up.

Maybe you need to try upgrading iPython. I am using version IPython 3.2.0.

Try upgrading Jupyter and iPython and let me know if that works for you.

Adam

I can replicate this bug with

Looks like plotly.py is broken in jupyter 4.1.x

Thanks, Adam & Etienne. In fact, I just tried it in a fresh install (‘pip install jupyter’) with Python 2.7 and Jupyter 4.1.0.

@DavidJBianco

I’m still working on a fix, but in the meantime you can try:

# Make plotly work with Jupyter notebook using the plotly.js CDN
init_notebook_mode(connected=True)

which appears to work as expected.

Thanks, Etienne. I did try that with my sample code, and for some reason I still couldn’t get it to show anything but a blank space. I even went so far as to restart the Python2 kernel, just to make sure I wasn’t caching something. I think I can make do with online mode for now, but if there’s anything you’d like me to try to help test the fix, just let me know.

1 Like

Ok.

Can you open your browser’s console and see if any errors are popping up? Thanks for your help.

Just one warning:

Widget frontend version does not match the backend. manager.js:112

@DavidJBianco

I think I found a solution. You can follow its progress here:https://github.com/plotly/plotly.py/pull/545

Thanks very much for checking into this, and for getting a PR done so quickly!

Hi,
I have the same problem. I have tried to roll back to jupyter_core 4.1.0, but I still have the problem.
I have tried to add ‘init_notebook_mode(connected=True)’, but does not work.

PR merged and published.

Updating to 1.12.7 should fix this issue.

1 Like

I update at the new version and It is working!
Great!! Thanks!!

This seems to be working now. Thanks so much for the quick turnaround!

I had a similar issue - cf https://github.com/plotly/plotly.py/issues/452
After updating to version 1.12.7, it seems to be working now.
Thx Etienne for your swift action !

had the same problem and updating fixed it for me yesterday, today the graphs are missing again. I’ve restarted the kernel and the server, no change (plotly version 1.12.18, jupyter version 4.1.0, ipython version 4.2.0). Any suggestions? Thanks.

Yikes.

you mean 1.12.8 ?

yes, sorry, 1.12.8. Graphs are appearing using iplot from ‘online’ mode (plotly.plotly), but iplot from plotly.offline just gives me white space.

Can you open your browser’s console and see if any errors are popping up? Thanks for your help.

so, creating a new notebook with the same code made the graphs appear. Chelsea had suggested it may be that an old version of plotly.js was cached in my notebook. It still seems odd to me that the update would work and then not work with the same browser/file, but I’m happy to have it working again. Thanks for your help.