Blank plots in jupyter notebook in offline mode

Hello,

i’m trying to run PLOTLY in offline mode on a disconnected computer (real offline !)

this simple code WORKS well when i run it IN CONSOLE mode (not via notebook):

import plotly#.plotly as py
import plotly.graph_objs as go

trace = {β€˜x’:[1,2],β€˜y’:[1,2]}
data = [trace]
fig = go.Figure(data = data, layout = {})

plotly.offline.plot(fig)

but fail to run in jupyter notebook producing blank plots (i see the space for the graph is used but no plots in it)
i did the required adjustments needed for notebook:

import plotly#.plotly as py
import plotly.graph_objs as go
plotly.offline.init_notebook_mode(connected=True)

trace = {β€˜x’:[1,2],β€˜y’:[1,2]}
data = [trace]
fig = go.Figure(data = data, layout = {})

plotly.offline.iplot(fig)

i think it because its really offline mode, when i connect the cable of the internet back its working , when disconnecting its not working, like its depend on something online and i need it to work on a standalone computer

thanks for anyhelp !

anyone ?

its seems its failing to load resource: plotly-latest.min.js
and i cant find this file in my local files … any thoughts?

I had a similar problem which I posted here and on StackOverflow.

What’s more, I actually got an answer which solved the problem for me over there - apparently plots not appearing can be a result of a too low data rate limit. Try changing the setting c.NotebookApp.iopub_data_rate_limit to a higher value in your jupyter notebook settings file, and see if that helps.

I first started seeing this issue running a notebook from within jupyter lab. When I ran it from the notebook app, this suggestion worked. Any way to get to work within jupyter lab?

Hi @mszczepaniak,

To display plots using iplot in JupyterLab, you’ll need to install the @jupyterlab/plotly-extension JupyterLab extension. See https://github.com/plotly/plotly.py#jupyterlab-support-python-35 for full installation instructions.

Hope that helps,
-Jon

1 Like

Thanks Jon. That did help. I was initially having trouble installing the extension, but eventually got it installed. After successfully installing the extension, it started working as expected.

1 Like