2

I try to plot table in Plotly in Python in Jupyter Lab. But my table in plotly does not show in Jupyter Lab, my code is as below:

df = pd.read_csv('df.csv')

fig = go.Figure(data=[go.Table(
    header=dict(values=list(df.columns),
                fill_color='paleturquoise',
                align='left'),
    cells=dict(values=[df.A, df.M, df.R, df.C, df.B, df.S, df.P, df.G, df.U],
               fill_color='lavender',
               align='left'))
])

fig.show()

I tried many ways like:

  1. fig.show('notebook')
  2. fig.show('jupyterlab')
  3. plotly.offline.init_notebook_mode(connected=True)
  4. pyo.init_notebook_mode()

But nothing works, I still do not see my ploytly table in Jupyter Lab, what can I do ?

dingaro
  • 2,156
  • 9
  • 29

2 Answers2

0

try with plotly.offline.iplot(fig) instead of fig.show()

import plotly.offline as py_offline

....

py_offline.iplot(fig)

Alternatively, you can use fig.show(renderer='notebook') check it up here https://plotly.com/python/renderers/

alec_djinn
  • 10,104
  • 8
  • 46
  • 71
0

Maybe this was your case... it was my one!

I had the very same problem. I mean, I installed plotly directly in the Jupyter Lab, and when I tried it there was only a blank space where the table should be, using the example copied from

https://plotly.com/python/table/

After many trials and wandering around I find the comment at plot.ly offline mode in jupyter lab not displaying plots by @eddygeek "I think so too, and I think you'd need restart Jupiter lab after installing it in order for changes to take effect." – Kareem Jeiroudi Apr 10, 2020 at 17:29

After restarting the Jupyter, things ran nicely!