Seaborn

Python สำหรับผู้ใช้ R

Daniel Chen

Instructor

Seaborn

  • แผนภูมิแท่ง: barplot
  • ฮิสโตแกรม: histplot
  • boxplot: boxplot
  • scatter plot: regplot
  • จุดเด่นของ Seaborn
    • กำหนดสีจุดตามข้อมูล
    • แบ่งกราฟย่อยตามข้อมูล
Python สำหรับผู้ใช้ R

ฮิสโตแกรมใน Seaborn

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

Python สำหรับผู้ใช้ R

Count plot ใน Seaborn

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

Python สำหรับผู้ใช้ R

Boxplot ใน Seaborn

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

Python สำหรับผู้ใช้ R

Scatter plot ใน Seaborn

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

Python สำหรับผู้ใช้ R

Scatter plot ใน Seaborn แบบไม่มีเส้นถดถอย

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

Python สำหรับผู้ใช้ R

Facet ใน Seaborn

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

Python สำหรับผู้ใช้ R

FacetGrid ใน Seaborn

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

Python สำหรับผู้ใช้ R

มาฝึกกันเถอะ!

Python สำหรับผู้ใช้ R

Preparing Video For Download...