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!

The guide didnā€™t work for me eitherā€¦ @cla did you solve the problem?

Iā€™m running into this issue (graphs not rendering) as well and havenā€™t had any luck resolving it despite following the jupyter install (Getting started with plotly in Python) and troubleshooting guide (Troubleshooting in Python). Iā€™ve even uninstalled jupyterlab and plotly a few times to no avail.

OS: Mac
plotly: 5.16.0
jupyter core packages
IPython : 8.14.0
ipykernel : 6.25.1
ipywidgets : 8.1.0
jupyter_client : 8.3.0
jupyter_core : 5.3.1
jupyter_server : 2.7.0
jupyterlab : 4.0.5
nbclient : 0.8.0
nbconvert : 7.7.3
nbformat : 5.9.2
notebook : 7.0.2
qtconsole : not installed
traitlets : 5.9.0

Iā€™m running and just a blank whitespace below.
fig = px.bar(x=[ā€œaā€, ā€œbā€, ā€œcā€], y=[1, 3, 2])
fig.show()

Anything else I should be trying?

Thanks
Sam