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...