บทนำ
วาด Swarm Plot แนวนอนเดี่ยวจากคอลัมน์เดียว ใช้ข้อมูลจาก Cricketers2.csv คอลัมน์ Matches
ขั้นตอน
- นำเข้าไลบรารีที่จำเป็น
- โหลดข้อมูล CSV เข้า DataFrame
- วาด Horizontal Swarm Plot:
sb.swarmplot(x=dataFrame["Matches"])
โค้ดเต็ม
import seaborn as sb
import pandas as pd
import matplotlib.pyplot as plt
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers2.csv")
sb.set_theme(style="whitegrid")
# Horizontal Swarm Plot สำหรับคอลัมน์ Matches
sb.swarmplot(x=dataFrame["Matches"])
plt.show()
ผลลัพธ์
ได้กราฟ Swarm Plot แนวนอนแสดงการกระจายจำนวนแมตช์ของนักคริกเก็ต