python - seaborn kde 图中的级别是什么意思?

标签 python seaborn contour kde kernel-density

我正在尝试制作二维数据的等高线图。但是,我想手动输入轮廓。我在 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


您可以通过两种方式描述级别 -
  • 在概率质量函数中指定所需的分区数(级别 = 5 生成 4 条等高线,将概率质量函数划分为 5 个部分)
  • 明确提及每个轮廓的阈值作为向量

  • 这里提到的分区描述了等高线图之外的区域。因此,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
    )
    
    enter image description here
    #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]
    )
    
    enter image description here

    关于python - seaborn kde 图中的级别是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64362044/

    相关文章:

    plot - Gnuplot: "all contours drawn in a single color"不起作用

    python - 在 tensorflow 中,如何迭代存储在张量中的一系列输入?

    python - Pandas :如何将多个单元格与列表/元组进行比较

    python - discord.py 机器人重写 AttributeError : 'Bot' object has no attribute 'send_message'

    python - 无法在 seaborn distplot 中显示图例

    python - `ValueError: operands could not be broadcast together` 尝试使用 Seaborn 从 DataFrame 列绘制单变量分布时

    python - 使用 cgitb 获取 HTML 正文

    python - 日期列和整数列之间的 Seaborn 热图

    r - 使用 geom_contour_filled 手动设置等高线图的比例

    opencv - (Opencv)在IplImage上获取轮廓