How to display plotly outputs in google collaboratory notebooks?
plotly
version 4.x
As of version 4, plotly
renderers know about Colab, so the following is sufficient to display a figure in both Colab and Jupyter (and other notebooks like Kaggle, Azure, nteract):
import plotly.graph_objects as go
fig = go.Figure( go.Scatter(x=[1,2,3], y=[1,3,2] ) )
fig.show()
plotly
version 3.x
I was also struggling to display the plotly graphs in Google colab and stumbled upon this thread where you explained the problems with different solutions over the net. Feelings are the same for each one of the solutions. Finally, my search ended when I came across this video.
I followed his approach (might be similar to the ones you already tried) and this worked for me.
- Upgrade plotly in colab thru !pip install plotly --upgrade and restart runtime as suggested.
- Comment the upgrade option before re-running your notebook
- Define the function configure_plotly_browser_state()
- Invoke plotly libraries
Call function and notebook mode like below in every cell where you want to call iplot
configure_plotly_browser_state()
init_notebook_mode(connected=False)
iplot(XXXXXX)
Just import plotly libraries
Please let me know if this helps :)
Add line '%matplotlib inline' at the beginning of notebooks
Refer below link: https://github.com/jupyter/notebook/issues/3523