Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seaborn - displot normalize KDEs for two different sample batches

I was wondering if there is a quick way to normalize the KDE curves (such that the integral of each curve is equal to one) for two displayed sample batches (see figure below).

So far I use:

sb.displot(data=proc, x="TPSA", hue="Data", kind="kde", legend=False)

Giving me the following plot:

non-normalized KDE Plot.

Thanks in advance for the help.

like image 811
lenskapopenska Avatar asked Jan 23 '26 22:01

lenskapopenska


1 Answers

When the hue parameter is set, seaborn by default normalises with respect to the area of all kde curves combined. If you'd like to normalise each curve independently (so the area under each curve is 1), you should provide the displot/kdeplot with common_norm=False.

e.g. in your case

sb.displot(data=proc, x="TPSA", hue="Data", kind="kde", legend=False, 
           common_norm=False)
like image 156
Tom B. Avatar answered Jan 25 '26 10:01

Tom B.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!