Lineplot ใน Seaborn ใช้เพื่อวาดเส้นโครงที่มีความเป็นไปได้ของการจัดกลุ่มความหมายหลายกลุ่ม seaborn.lineplot() ใช้สำหรับสิ่งนี้
สมมติว่าต่อไปนี้คือชุดข้อมูลของเราในรูปแบบไฟล์ CSV – Cricketers.csv
ขั้นแรก นำเข้าไลบรารีที่จำเป็น 3 แห่ง –
import seaborn as sb import pandas as pd import matplotlib.pyplot as plt
โหลดข้อมูลจากไฟล์ CSV ลงใน Pandas DataFrame -
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers.csv")
ตัวอย่าง
ต่อไปนี้เป็นรหัส -
import seaborn as sb
import pandas as pd
import matplotlib.pyplot as plt
# Load data from a CSV file into a Pandas DataFrame
dataFrame = pd.read_csv("C:\\Users\\amit_\\Desktop\\Cricketers.csv")
print("\nReading the CSV file...\n",dataFrame)
# Age in kgs
x = dataFrame['Age']
# Height in Inches
y = dataFrame['Height']
# plot lineplot with Age and Height
sb.lineplot(x,y)
plt.ylabel("Height (inches)")
plt.show() ผลลัพธ์
สิ่งนี้จะสร้างผลลัพธ์ต่อไปนี้ -
