'Plotly Table does not show in Jupyter Lab in Python?
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:
fig.show('notebook')
fig.show('jupyterlab')
plotly.offline.init_notebook_mode(connected=True)
pyo.init_notebook_mode()
But nothing works, I still do not see my ploytly table in Jupyter Lab, what can I do ?
Solution 1:[1]
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/
Solution 2:[2]
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!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | |
Solution 2 | Carlos Augusto Frana Schettini |