我正在尝试制作二维数据的等高线图。但是,我想手动输入轮廓。我在 seaborn.kde documentation 中找到了“级别”选项,我可以在这里手动定义轮廓的级别。但是,我不知道这些级别是什么意思。文档给出了这个定义 -
Levels correspond to iso-proportions of the density.
密度的等比是什么意思?
有没有我可以阅读的引用资料?
最佳答案
level
这里描述了低于给定阈值的累积质量。如 documentation 中的示例所述.
Number of contour levels or values to draw contours at. A vector argument must have increasing values in [0, 1]. Levels correspond to iso-proportions of the density: e.g., 20% of the probability mass will lie below the contour drawn for 0.2. Only relevant with bivariate data
您可以通过两种方式描述级别 -
这里提到的分区描述了等高线图之外的区域。因此,0.2 意味着 20% 的概率质量位于代表 20% 的第一个轮廓之外。使用以下代码可以更清楚地了解这一点。
我展示了下面的两种实现供您引用。
import seaborn as sns
geyser = sns.load_dataset("geyser",)
#Levels as equal cuts in the probability mass function
sns.kdeplot(
data=geyser, x="waiting", y="duration", hue="kind",
levels=5
)
#Levels as explicitly described cuts in the probability mass function
sns.kdeplot(
data=geyser, x="waiting", y="duration", hue="kind",
levels=[0.3, 0.4, 0.8]
)
关于python - seaborn kde 图中的级别是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64362044/