Seaborn

給 R 使用者的 Python

Daniel Chen

Instructor

Seaborn

  • 長條圖:barplot
  • 直方圖:histplot
  • 盒鬚圖:boxplot
  • 散佈圖:regplot
  • Seaborn 優點
    • 依資料著色
    • 依資料分面
給 R 使用者的 Python

Seaborn 直方圖

import seaborn as sns
import matplotlib.pyplot as plt
sns.histplot(iris['sepal_length'], kde = True)
plt.show()

給 R 使用者的 Python

Seaborn 計數圖

sns.countplot('species', data=iris)
plt.show()

給 R 使用者的 Python

Seaborn 盒鬚圖

sns.boxplot(x='species', y='sepal_length', data=iris)
plt.show()

給 R 使用者的 Python

Seaborn 散佈圖

sns.regplot(x='sepal_length', y='sepal_width', data=iris)
plt.show() 

給 R 使用者的 Python

Seaborn 散佈圖(無回歸線)

sns.regplot(x='sepal_length', y='sepal_width', data=iris,
            fit_reg=False)
plt.show()

給 R 使用者的 Python

Seaborn 分面圖

sns.lmplot(x='sepal_length', y='sepal_width', data=iris,
           fit_reg=False,
           col='species')
plt.show() 

給 R 使用者的 Python

Seaborn FacetGrid

g = sns.FacetGrid(iris, col="species")
g = g.map(plt.hist, "sepal_length")
plt.show()

給 R 使用者的 Python

一起來練習吧!

給 R 使用者的 Python

Preparing Video For Download...