A kernel density estimate (sns.kdeplot) draws a smooth curve approximating the distribution — easier to compare across groups than jagged histograms, since overlapping curves read cleanly.
Smooth densities
sns.kdeplot(data=penguins, x="flipper_length_mm", hue="species")sns.kdeplot(data=penguins, x="flipper_length_mm", hue="species",fill=True, alpha=0.4) # shadedsns.kdeplot(data=penguins, x="bill_length_mm", y="bill_depth_mm") # 2-D density
The smoothing caveat
Key takeaways
- 01sns.kdeplot draws a smooth density curve — great for comparing shapes across groups.
- 02fill=True shades under the curve; a 2-D KDE (x and y) shows joint density.
- 03bw_adjust controls smoothing — too much hides structure, too little adds noise.
- 04For small or bounded data, a histogram is more honest than a KDE.
