Plots not showing up in Jupyter Lab (Plotly 3.0)


#1

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.


#2

Hey @shreyasbapat

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


#3

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


#4

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.


#5

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


#6

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


#7

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


#8

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


#9

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