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

Seaborn 資料視覺化入門

Content Team

DataCamp

為 AxesSubplot 加入標題

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

g.figure.suptitle("New Title", y=1.03)
AxesSubplot
g = sns.boxplot(x="Region", 
                y="Birthrate", 
                data=gdp_data)

g.set_title("New Title", y=1.03)
Seaborn 資料視覺化入門

子圖標題

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

依子群的出生率箱型圖

Seaborn 資料視覺化入門

子圖標題

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

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

含圖形標題的子群出生率箱型圖

Seaborn 資料視覺化入門

子圖標題

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

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

g.set_titles("This is {col_name}")

含子圖標題的子群出生率箱型圖

Seaborn 資料視覺化入門

加入座標軸標籤

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

g.set(xlabel="New X Label", ylabel="New Y Label")
plt.show()

含座標軸標籤的出生率箱型圖

Seaborn 資料視覺化入門

旋轉 x 軸刻度標籤

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

plt.xticks(rotation=90)
plt.show()

旋轉 x 刻度標籤的出生率箱型圖

Seaborn 資料視覺化入門

一起來練習吧!

Seaborn 資料視覺化入門

Preparing Video For Download...