-1

I got a DataFrame with 3 labels, and KDE was plotted with code below.

Theoretically, the three lines should plot gaussian distributions, and calculus to 1 independently. However, the plotting shows that their density may be estimated jointly.

How should I estimate them independently? And got three gaussian distribution lines with equal calculus?

df = pd.DataFrame(data=data, columns=['label', 'score'])
l = sns.displot(data=df, x="score",hue="label", kind="kde", rug=False)

enter image description here

Ink
  • 845
  • 1
  • 13
  • 31

1 Answers1

3

As per sns.displot documentation, using kind = 'kde' it also accepts arguments from sns.kdeplot function. In that case, you can see you have an argument common_norm available, which is defined as:

If True, scale each conditional density by the number of observations such that the total area under all densities sums to 1. Otherwise, normalize each density independently.

So, you just need to add common_norm = False to your sns.displot() call.

Default behavior on seaborn tips dataset:

enter image description here

After setting common_norm = False:

enter image description here

dm2
  • 4,053
  • 3
  • 17
  • 28