Python Seaborn 散点矩阵图 - sns.pairplot() 代码示例
以下是 Python 使用 Seaborn 库中的 sns.pairplot() 函数绘制散点矩阵图的示例代码:
import seaborn as sns
import matplotlib.pyplot as plt
# 加载数据集
iris = sns.load_dataset('iris')
# 绘制散点矩阵图
sns.pairplot(iris)
# 显示图形
plt.show()
在这个示例中,我们使用 Seaborn 库中的 load_dataset() 函数加载了一个经典的鸢尾花数据集。然后,我们使用 pairplot() 函数绘制了一个散点矩阵图,其中每个变量都与其他变量进行了比较。最后,我们使用 Matplotlib 库中的 show() 函数显示了图形。
原文地址: https://www.cveoy.top/t/topic/f0ik 著作权归作者所有。请勿转载和采集!