IBM Support

"Plotly" produced blank graph in Jupyter Lab IDE.

Question & Answer


Question

Following code is working correctly to display graph in Jupyter Notebook. However, if in Jupyter Lab, it produced blank graph instead.
import plotly.express as px
fig = px.bar(x=["a", "b", "c"], y=[1, 3, 2])
fig.show()
Could you tell me how to allow Jupyter Lab to display Plotly graph correctly?

Cause

You need to set the appropriate renderer in Jupyter Lab to allow Plotly displays figure correctly.

Answer

As suggested in the Plotly documentation, you might set the default renderer explicitly as iframe or collab by adding following lines into your codes:
import plotly.io as pio
pio.renderers.default = 'iframe' # or 'colab' or 'iframe' or 'iframe_connected' or 'sphinx_gallery'
[Sample]
image-20221227120239-1

Related Information

[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU059","label":"IBM Software w\/o TPS"},"Product":{"code":"SSHE3N","label":"IBM Watson Studio Premium for IBM Cloud Pak for Data"},"ARM Category":[{"code":"a8m50000000L1dGAAS","label":"Analyze-\u003EModels-\u003ENotebooks"}],"ARM Case Number":"TS011252507","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

Modified date:
27 December 2022

UID

ibm16851811