開始使用免費開始

FacetGrid 與 AxesSubplot

在前一個課程中,我們學到 Seaborn 的繪圖函式會建立兩種不同型別的物件:FacetGrid 物件與 AxesSubplot 物件。為圖表加上標題的方法,會因為物件型別而不同。

在提供的程式碼中,我們使用 relplot() 與 miles per gallon 資料集建立了一個散佈圖,呈現車重與馬力之間的關係。這個散佈圖被指定給變數 g。請判斷它是哪一種物件。

我們已經將 Seaborn 以 sns 匯入,並將 matplotlib.pyplotplt 匯入。

本練習屬於課程

Seaborn 資料視覺化入門

檢視課程

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Create scatter plot
g = sns.relplot(x="weight", 
                y="horsepower", 
                data=mpg,
                kind="scatter")

# Identify plot type
type_of_g = ____

# Print type
print(type_of_g)
編輯並執行程式碼