Black Lives Matter. Please consider donating to Black Girls Code today.

Plots not showing up in Jupyter Lab (Plotly 3.0)

I can simply not see anything plotted in Jupyter Lab. When I use init_notebook_mode, it shows a blank space for plots but the plot is still not shown.

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

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

iplot({
“data”: [go.Bar(x=keys, y=values)],
“layout”: go.Layout(title=“Sample Bar Chart”)
})
This simply gives no output.

Hey @shreyasbapat

try adding plotly.offline.init_notebook_mode(connected=True) https://plot.ly/python/getting-started/#initialization-for-offline-plotting

Hi! I am sorry. It’s solved. I installed the plotly extension for Jupyter Lab

2 Likes

Hi, I am having a similar issue but have installed the plotly extension for Jupyter Lab. I’m using example code from the Plotly choropleth tutorial:

I have tried a number of fixes but still can’t get plotting offline to work with jupyter lab. All my plots do show up in my plotly profile, but if I could get some help getting them to display in jupyter lab, I’d really appreciate it!

Thanks.

Hi @asatmel,

In this screenshot you provided it looks like you’re using the online (not offline) iplot method. I’m not sure why you’re not seeing the online plot, but in any case if you want to do offline plotting with iplot you need to use the plotly.offline.iplot method, and you need to have the @jupyterlab/plotly-extension extension installed.

Hope that helps!
-Jon

Hi @jmmease,

Thanks for your help. I’ve tried using the plotly.offline.iplot method, and I do have the @jupyterlab/plotly-extension installed, but now I’m getting a weird issue where the plot output area is way too small. When I’ve tried with some of my own data, I’ve got a similar problem where the choropleth plot’s colorbar and title will show but not the map.

I think the issue might have to do with my @jupyterlab/plotly-extension installation. Could that be a reason for the strange figure output? I tried uninstalling the extension and reinstalling it, but that didn’t seem to help. Is this something you’ve seen before?

Thanks,
Aven

Hi @asatmel,

Hmm, that’s interesting. Here are a couple of thoughts. The @jupyterlab/plotly-extension tries to resize the figure responsively as the notebook’s width changes (by clicking and dragging usually). I have noticed sometimes that the plot shows up very small for a split-second in the beginning, and then expands to fill the output cell. So for some reason, the resize events aren’t being emitted or processed right in your case.

Does the plot react if you drag to resize the width of your browser?

Could you open an issue on the issue tracker for the @jupyterlab/plotly-extension? This way we can get the maintainer involved. In the issue, please include the output of pip list (and conda list if you’re using conda) and jupyter labextension list.

Thanks for bringing this up!
-Jon

2 Likes

Hi @jmmease

So the plots weren’t reacting when I tried resizing the width of the browser, but then I happened to check whether or not my browser (Firefox) was updated and it was not, and after it updated and I restarted the browser, the plots started showing up correctly.

Easy fix and hopefully helpful to others.

Thanks for your support on the issue!

Aven

Awesome! Thanks for sharing what worked for you.
-Jon

Hey,

I have the same issue, were you able to solve this ?

Same issue. Solved.

$ npm install --save plotlywidget

plus commands here https://github.com/plotly/plotly.py#jupyterlab-support-python-35

Then, obviously, restart jupyter service

For future visitors to this thread: we have a Troubleshooting guide now! https://plot.ly/python/troubleshooting/

Hi,
I have the same problem. I have checked the troubleshooting guide (thank you! @nicolaskruchten) but unfortunately could not fix the problem.
I am on macOS Catalina (10.15.3), Firefox 73.01, with the following installed:
$ jupyter --version
jupyter core : 4.6.1
jupyter-notebook : 6.0.1
qtconsole : not installed
ipython : 7.11.1
ipykernel : 5.1.3
jupyter client : 5.3.3
jupyter lab : 1.2.4
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.3
traitlets : 4.3.3

[Also plotly.version is ‘4.5.2’ ]

As a test, i have tried to run the code here: https://plot.ly/python/graphing-multiple-chart-types/
but all I get is a big blank space.


All help welcome!