Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> Python

วิธีใช้ Seaborn แสดง Kernel Density Estimation Plot (jointplot) ใน Python

Seaborn visualize ข้อมูล Kernel Density Estimation (KDE) ประมาณ probability density function ของ continuous random variable ใช้สำหรับ non-parametric analysis jointplot ถ้า kind='kde' จะพล็อต KDE plot

ตัวอย่าง

import pandas as pd
import seaborn as sb
from matplotlib import pyplot as plt
my_df = sb.load_dataset('iris')
sb.jointplot(x='petal_length', y='petal_width', data=my_df, kind='kde')
plt.show()

ผลลัพธ์

วิธีใช้ Seaborn แสดง Kernel Density Estimation Plot (jointplot) ใน Python

คำอธิบาย

  • นำเข้าแพ็กเกจ
  • โหลดข้อมูล 'iris' จาก seaborn
  • เก็บใน DataFrame
  • ใช้ 'jointplot' kind='kde' ระบุ x, y
  • แสดง KDE plot

Jointplot แสดง bivariate distribution (KDE/contour) พร้อม univariate marginal distributions ด้านข้าง