Introduction to Seaborn

การสร้างภาพข้อมูลด้วย Seaborn เบื้องต้น

Content Team

DataCamp

Seaborn คืออะไร?

  • ไลบรารีแสดงผลข้อมูลด้วย Python
  • สร้างกราฟประเภทที่ใช้บ่อยได้ง่าย

Box plot ของยอดเงินรวมแยกตามวันและเพศ

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)

  • ซีรีส์โทรทัศน์ "The West Wing"
การสร้างภาพข้อมูลด้วย Seaborn เบื้องต้น

ตัวอย่างที่ 1: Scatter plot

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()

Scatter plot ของส่วนสูงและน้ำหนัก

การสร้างภาพข้อมูลด้วย Seaborn เบื้องต้น

ตัวอย่างที่ 2: สร้าง Count plot

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()

Count plot ของเพศ

การสร้างภาพข้อมูลด้วย Seaborn เบื้องต้น

Scatter plot ที่มีสีดำและสีแดง

Line plot ที่มีจุดกำกับและเส้นทึบ

Point plot ของความเป็นชายพร้อม hue

Scatter plot ของแรงม้าเทียบกับ mpg พร้อม sequential palette

1 Waskom, M. L. (2021). seaborn: statistical data visualization. https://seaborn.pydata.org/
การสร้างภาพข้อมูลด้วย Seaborn เบื้องต้น

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

การสร้างภาพข้อมูลด้วย Seaborn เบื้องต้น

Preparing Video For Download...