タイトルとラベルの追加: パート 1

Seaborn を使ったデータ可視化入門

Content Team

DataCamp

情報がしっかり伝わる可視化の作成

Box plot of birth rate per region

Box plot of birth rate per region with title and labels

Seaborn を使ったデータ可視化入門

FacetGridと AxesSubplotオブジェクト

Seabornのプロットでは、2種類のオブジェクトが作成されます:FacetGrid と AxesSubplot

g = sns.scatterplot(x="height", y="weight", data=df)

type(g)
> matplotlib.axes._subplots.AxesSubplot
Seaborn を使ったデータ可視化入門

空のFacetGrid

Empty 4x4 FacetGrid

Seaborn を使ったデータ可視化入門

FacetGridと AxesSubplotオブジェクト

オブジェクトの型 プロットの種類 特徴
FacetGrid relplot(), catplot() サブプロットを作成できる
AxesSubplot scatterplot(), countplot() など 単一のプロットのみ作成できる
Seaborn を使ったデータ可視化入門

FacetGridにタイトルを追加する

g = sns.catplot(x="Region", 
                y="Birthrate", 
                data=gdp_data, 
                kind="box")

g.figure.suptitle("New Title")
plt.show()

Birth rate box plot with title added

Seaborn を使ったデータ可視化入門

FacetGridのタイトルの位置を調整する

g = sns.catplot(x="Region", 
                y="Birthrate", 
                data=gdp_data, 
                kind="box")

g.figure.suptitle("New Title", 
               y=1.03)

plt.show()

Birth rate plot with higher title

Seaborn を使ったデータ可視化入門

練習しましょう!

Seaborn を使ったデータ可視化入門

Preparing Video For Download...