plotly.offline.iplot gives a large blank field as its output in Jupyter Notebook/Lab

Each Answer to this Q is separated by one/two green lines.

I am trying to create a Sankey chart in a Jupyter notebook, basing my code on the first example shown here.

I ended up with this, which I can run without getting any errors:

import numpy as npy
import pandas as pd
import plotly as ply


df = pd.read_csv('C:\\Users\\a245401\\Desktop\\Test.csv',sep=';')


data_trace = dict(
    domain = dict(
      x =  [0,1],
      y =  [0,1]
    orientation = "h",
    valueformat = ".0f",
    node = dict(
      pad = 10,
      thickness = 30,
      line = dict(
        color = "black",
        width = 0.5
      label =  df['Node, Label'].dropna(axis=0, how='any'),
      color = df['Color']
    link = dict(
      source = df['Source'].dropna(axis=0, how='any'),
      target = df['Target'].dropna(axis=0, how='any'),
      value = df['Value'].dropna(axis=0, how='any'),

layout =  dict(
    title = "Test",
    height = 772,
    width = 950,
    font = dict(
      size = 10

fig = dict(data=[data_trace], layout=layout)
ply.offline.iplot(fig, filename="Test")

With the csv-file looking like this:

Source;Target;Value;Color;Node, Label
0;2;2958.5;#262C46;Test 1
0;2;236.7;#262C46;Test 2
0;2;1033.4;#262C46;Test 3
0;2;58.8;#262C46;Test 4
0;2;5.2;#262C46;Test 5
0;2;9.4;#262C46;Test 6
0;2;3.4;#262C46;Test 7

It seems to run fine, with the various outputs looking right at a first glance, but the final output from ply.offline.iplot(fig, filename="Test") just shows a large blank field:
enter image description here
The terminal looks like this after having run all the cells in the notebook once:
enter image description here

Can someone please point me to where I am going wrong here?

I have had similar issues with plotly offline in Jupyter in the past – sometimes it’s surprisingly inconsistent when/why the plots fail to appear. It may be worth a try starting with an increased data rate limit.

jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10

For me helped change notebook to Trusted (this enabled Javascript and give plotly way to build graph into the jupyter notebook.).

This option you can found here:

In upper right side of notebook

I tried all the solutions suggested here, but none of them worked for me. What solved the issue was adding:

import as pio

and also using"notebook") rather than simply, as suggested here.

When using Google Colab, include the snippet –

import as pio

Or use the overall import statements as –

import plotly.offline as py
import plotly.graph_objs as go
import as pio
from plotly.offline import init_notebook_mode, iplot

This will set the rendering to Colab style and the plots will be displayed.

Hope this helps.

I can get the correct display with jupyter notebook server (without any additional options), but get a blank block
with jupyter lab server
. Related version info:

$ jupyter lab --version
$ jupyter notebook --version
$ python -c "import plotly; print(plotly.__version__)"

So for those who are using JupyterLab, to properly display the offline plotly graphs in JupyterLab, we need to install the plotly-extension with following commands (following is excerpted from a related answer):

$ jupyter labextension install @jupyterlab/plotly-extension
$ jupyter labextension list 
$ jupyter lab build

If none of these answers worked for you. Try this one

just do this in conda prompt opened with administrator permission

pip install pip --upgrade
conda upgrade notebook or pip install notebook --upgrade

conda install -c conda-forge ipywidgets or pip install ipywidgets

You need to have the latest versions of jupyter notebook and ipywidgets.

I have myself encountered a similar issue, with a sunburst plot. The blank plot was due to invalid data. I would have expected to get an error at runtime, but it appears that in some rare cases, no error is raised, and a blank plot is displayed instead.

Therefore, check your data validity, or perform a test with dummy data provided on plotly doc, in order to test if the problem comes from data or plotly/notebook interface.

From the quickstart in the README

This displays a figure, while none of the other answers here worked for me:

import plotly.graph_objs as go
fig = go.FigureWidget()
# Display an empty figure

This (in a new cell) modifies the above plot with a bar and line chart:

# Add a scatter chart
fig.add_scatter(y=[2, 1, 4, 3])
# Add a bar chart
fig.add_bar(y=[1, 4, 3, 2])
# Add a title
fig.layout.title="Hello FigureWidget"

If that doesn’t work, make sure your install is good, e.g. pip install --user --upgrade plotly if you installed with pip

Some of above methods did work for me. But I solve this kind of problem untimately according to this discussion and the official troubleshooting guide.

  • Step 1:
    Close your jupyter lab. Then, uninstall plotly and some extensions.
$ conda remove plotly
$ jupyter labextension uninstall jupyterlab-plotly
$ jupyter labextension uninstall plotlywidget
  • Step2: Open terminal from the same environment as JupyterLab was launched to rebuild jupyter lab.
$ jupyter lab build
  • Step 3: Reinstall plotly and jupyter lab extensions with same versions
$ conda install plotly
$ jupyter labextension install jupyterlab-plotly
$ jupyter labextension install plotlywidget

Above precedures work fine for me in jupyter lab. I think we can try same precedures like it in jupyter notebook.

On my side the culprit was the “Darker Jupyter” addon I was using on firefox.

include these lines:

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

works for me

My response might be a little too late, but along with Plotly its also important to import plotly.graph.

These are the packages you need to import. I was getting the blank outputs too, and this worked for me.

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

I had almost a similar issue while trying to plot a heatmap in colab, for me the below solution helped:

import plotly.graph_objs as go
from plotly.offline import iplot
import chart_studio.plotly as py

# these two lines are what allow your code to show up in a notebook
import as pio

corr = data.corr()

trace = go.Heatmap(z=corr.values,
iplot(data, filename="basic-heatmap")

The answers/resolutions are collected from stackoverflow, are licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0 .