要创建等高线图,可以使用Seaborn中的kdeplot
函数,设置参数shade=True
来生成等高线图。以下是一个示例代码:
import seaborn as sns
import matplotlib.pyplot as plt
# 生成数据
data = sns.load_dataset("iris")
# 创建等高线图
sns.kdeplot(data=data, x="sepal_length", y="sepal_width", shade=True, thresh=0.05)
plt.show()
这段代码会生成一个基于鸢尾花数据集中sepal_length
和sepal_width
两个特征的等高线图。你也可以根据自己的数据集和需要来调整参数,以生成符合需求的等高线图。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
相关推荐:Seaborn怎么创建填充的等高线图