Seaborn 入門

Seaborn 資料視覺化入門

Content Team

DataCamp

什麼是 Seaborn?

  • Python 資料視覺化函式庫
  • 輕鬆建立常見圖表類型

每週各天總帳單的盒鬚圖,依男性與女性分組

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn 資料視覺化入門

為何 Seaborn 有用?

資料分析工作流程圖

Seaborn 資料視覺化入門

Seaborn 的優點

  • 易於使用
  • pandas 資料結構相容良好
  • 建立於 matplotlib 之上
Seaborn 資料視覺化入門

開始使用

import seaborn as sns

import matplotlib.pyplot as plt

Samuel Norman Seaborn(sns

  • 「白宮風雲」電視影集
Seaborn 資料視覺化入門

範例 1:散佈圖

import seaborn as sns
import matplotlib.pyplot as plt

height = [62, 64, 69, 75, 66, 68, 65, 71, 76, 73] weight = [120, 136, 148, 175, 137, 165, 154, 172, 200, 187]
sns.scatterplot(x=height, y=weight)
plt.show()

身高對體重的散佈圖

Seaborn 資料視覺化入門

範例 2:建立次數圖

import seaborn as sns
import matplotlib.pyplot as plt

gender = ["Female", "Female", "Female", "Female", "Male", "Male", "Male", "Male", "Male", "Male"]
sns.countplot(x=gender)
plt.show()

性別的次數圖

Seaborn 資料視覺化入門

使用黑色與紅色色調的散佈圖

含標記與實線的折線圖

含色調的男性氣質點圖

馬力對每加侖英里數的散佈圖(序列調色盤)

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
Seaborn 資料視覺化入門

一起來練習吧!

Seaborn 資料視覺化入門

Preparing Video For Download...