'Does anyone know how to use plotly express offline?
I am trying to run an example code to visualise a plotly chart, as below:
import plotly.express as px
from plotly.offline import init_notebook_mode, iplot, plot
import plotly.offline as py
py.init_notebook_mode(connected=True)
%matplotlib inline
df = pd.DataFrame([
['Europe', 586098529, 'Total'], ['Asia', 3811953827, 'Total'],
['France', 61083916, 'Europe'], ['Germany', 82400996, 'Europe'], ['Italy', 58147733, 'Europe'],
['Spain', 40448191, 'Europe'], ['United Kingdom', 60776238, 'Europe'], ['Taiwan', 23174294, 'Asia'],
['Japan', 127467972, 'Asia'], ['Korean', 49044790, 'Asia'], ['China', 1318683096, 'Asia']],
columns=['country', 'pop', 'continent'])
fig = px.sunburst(df, names='country', values='pop', parents='continent', title='Population')
plot(fig,show_link = False)
When I run this, a new internet browser opens up to show the chart. Is there a way to show this just in Jupyter itself?
Solution 1:[1]
- as @r-beginners mentioned, fig.show() displays a graph in Jupyter
- check if you've installed
ipywidgets>=7.5for Jupyter Notebook orjupyterlab-plotlyandplotlywidgetfor Jupyter Lab - check out this StackOverflow discussion
- getting started guide by plotly
- troubleshooting guide
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 | Konstantin Z |
