開始使用免費開始

變更樣式與調色盤

回到我們的資料集:這是針對年輕人關於其習慣與偏好的問卷結果。我們已提供程式碼,用來繪製他們對「你多常聽取父母的建議?」這個問題之作答次數圖。現在來調整樣式與調色盤,讓圖表更容易解讀。

我們已經將 Seaborn 匯入為 sns,並將 matplotlib.pyplot 匯入為 plt

本練習屬於課程

Seaborn 資料視覺化入門

檢視課程

動手互動練習

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

# Set the style to "whitegrid"


# Create a count plot of survey responses
category_order = ["Never", "Rarely", "Sometimes", 
                  "Often", "Always"]

sns.catplot(x="Parents Advice", 
            data=survey_data, 
            kind="count", 
            order=category_order)

# Show plot
plt.show()
編輯並執行程式碼