pythonpandasmatplotlibseabornkdeplot

What is the meaning of "multiple" parameter in Seaborn's kdeplot?


I am trying to understand the meaning of multiple parameter in Seaborn's kdeplot. Below is taken from its documentation,

multiple{{“layer”, “stack”, “fill”}}

Method for drawing multiple elements when semantic mapping creates subsets. Only relevant with univariate data.

However it doesn't help much and their plots looks very different. I would appreciate it if someone can elaborate them more.

Here are the plots created with setting multiple to layer, stack and fill respectively,

sns.displot(data=bg_vs_non_bg, multiple="layer", x="Value", hue="ClassName", kind="kde", col="Modality", log_scale=True, fill=True)

multiple="layer"

sns.displot(data=bg_vs_non_bg, multiple="stack", x="Value", hue="ClassName", kind="kde", col="Modality", log_scale=True)

multiple="stack"

sns.displot(data=bg_vs_non_bg, multiple="fill", x="Value", hue="ClassName", kind="kde", col="Modality", log_scale=True)

enter image description here


Solution

  • You can think of it like this:

    Option Meaning Explanation
    layer Original density The densities are overlaid on each other, so the y-value just represents the original density of each curve.
    stack Stacked density The densities are stacked on each other, so the y-value represents the stacked sum of the densities, i.e, the second curve's y-value is the sum of the first and second densities.
    fill Proportional density The densities are normalized to sum to 1, so the y-value represents the proportional density of each curve relative to the others.

    Or in visual form:

    visual comparison