Seaborn

Python cho người dùng R

Daniel Chen

Instructor

Seaborn

  • biểu đồ cột: barplot
  • biểu đồ tần suất: histplot
  • boxplot: boxplot
  • scatter plot: regplot
  • Ưu điểm của Seaborn
    • tô màu điểm theo dữ liệu
    • chia ô (facet) theo dữ liệu
Python cho người dùng R

Biểu đồ tần suất với Seaborn

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

Python cho người dùng R

Biểu đồ đếm với Seaborn

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

Python cho người dùng R

Boxplot với Seaborn

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

Python cho người dùng R

Scatter plot với Seaborn

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

Python cho người dùng R

Scatter plot Seaborn không có đường hồi quy

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

Python cho người dùng R

Facet trong Seaborn

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

Python cho người dùng R

Seaborn FacetGrid

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

Python cho người dùng R

Cùng luyện tập nào!

Python cho người dùng R

Preparing Video For Download...