加入標題與標籤:第 1 部分

Seaborn 資料視覺化入門

Content Team

DataCamp

製作有資訊量的視覺化

各地區出生率的盒鬚圖

含標題與標籤的各地區出生率盒鬚圖

Seaborn 資料視覺化入門

FacetGrid 與 AxesSubplot 物件

Seaborn 圖會建立兩種物件:FacetGridAxesSubplot

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

type(g)
> matplotlib.axes._subplots.AxesSubplot
Seaborn 資料視覺化入門

空白 FacetGrid

空的 4x4 FacetGrid

Seaborn 資料視覺化入門

FacetGrid 與 AxesSubplot 物件

Object Type Plot Types Characteristics
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()

加入標題的出生率盒鬚圖

Seaborn 資料視覺化入門

調整 FacetGrid 標題高度

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

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

plt.show()

標題位置較高的出生率圖

Seaborn 資料視覺化入門

一起來練習吧!

Seaborn 資料視覺化入門

Preparing Video For Download...