目標



・たった1行で動くグラフを作成



内容



・plotly、plotly_expressのインストール方法

・plotly_expressのインポート方法

・help機能の使い方(★必須ツール★)

・データの用意(事前の準備不要)

・動く円グラフ作成

plotlyのインストール方法
In [2]:
pip install plotly
Requirement already satisfied: plotly in /opt/anaconda3/lib/python3.7/site-packages (4.8.2)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from plotly) (1.14.0)
Requirement already satisfied: retrying>=1.3.3 in /opt/anaconda3/lib/python3.7/site-packages (from plotly) (1.3.3)
Note: you may need to restart the kernel to use updated packages.
plotly_expressのインストール方法
In [3]:
pip install plotly_express
Requirement already satisfied: plotly_express in /opt/anaconda3/lib/python3.7/site-packages (0.4.1)
Requirement already satisfied: plotly>=4.1.0 in /opt/anaconda3/lib/python3.7/site-packages (from plotly_express) (4.8.2)
Requirement already satisfied: scipy>=0.18 in /opt/anaconda3/lib/python3.7/site-packages (from plotly_express) (1.4.1)
Requirement already satisfied: statsmodels>=0.9.0 in /opt/anaconda3/lib/python3.7/site-packages (from plotly_express) (0.11.0)
Requirement already satisfied: patsy>=0.5 in /opt/anaconda3/lib/python3.7/site-packages (from plotly_express) (0.5.1)
Requirement already satisfied: pandas>=0.20.0 in /opt/anaconda3/lib/python3.7/site-packages (from plotly_express) (1.0.5)
Requirement already satisfied: numpy>=1.11 in /opt/anaconda3/lib/python3.7/site-packages (from plotly_express) (1.18.5)
Requirement already satisfied: retrying>=1.3.3 in /opt/anaconda3/lib/python3.7/site-packages (from plotly>=4.1.0->plotly_express) (1.3.3)
Requirement already satisfied: six in /opt/anaconda3/lib/python3.7/site-packages (from plotly>=4.1.0->plotly_express) (1.14.0)
Requirement already satisfied: python-dateutil>=2.6.1 in /opt/anaconda3/lib/python3.7/site-packages (from pandas>=0.20.0->plotly_express) (2.8.1)
Requirement already satisfied: pytz>=2017.2 in /opt/anaconda3/lib/python3.7/site-packages (from pandas>=0.20.0->plotly_express) (2019.3)
Note: you may need to restart the kernel to use updated packages.
plotly_expressをインポート
In [4]:
import plotly.express as px
help機能の使い方

help(px)

データの用意
In [5]:
df=px.data.tips()
動く円グラフ作成
In [6]:
fig=px.sunburst(df,path = ['smoker','day','time','sex'],values='total_bill')
fig.show()