Distribution Plots: histplot, kdeplot, and ecdfplot0%
Distribution Plots: histplot, kdeplot, and ecdfplot
Beginner12 min read•Updated: Jul 11, 2026
Distribution Plots: histplot, kdeplot, and ecdfplot
Reading Time: 8 Mins | Level: Intermediate
1. Visualizing Distributions with Seaborn
Seaborn provides three dedicated functions for exploring distributions:
- 1
sns.histplot(): Modern flexible histogram with binning and optional KDE overlays. - 2
sns.kdeplot(): Kernel Density Estimation representing continuous probability density curves without arbitrary bin cutoffs. - 3
sns.ecdfplot(): Empirical Cumulative Distribution Function—the most rigorous statistical plot for percentiles.
2. Using sns.histplot() with kde=True and hue
Python
import seaborn as sns
import matplotlib.pyplot as plt
df = sns.load_dataset('tips')
fig, ax = plt.subplots(figsize=(8, 5))
# Plot total_bill distribution split by lunch vs dinner
sns.histplot(
data=df,
x='total_bill',
hue='time',
kde=True,
bins=25,
palette='Set2',
alpha=0.6,
ax=ax
)
ax.set_title('Total Bill Distribution by Meal Time')
plt.show()
3. What is an ECDF Plot (ecdfplot)?
An ECDF plot displays the exact proportion of observations less than or equal to a given value. It requires zero binning parameters, completely avoiding the subjectivity of choosing bin counts:
Python
# At what bill amount do 80% of customers fall below?
sns.ecdfplot(data=df, x='total_bill')
plt.axhline(0.80, color='red', linestyle=':')
plt.show()
Interactive Quiz
Multiple Choice Questions
Question 1
Which modern Seaborn function replaces the legacy
sns.distplot() for plotting histograms and density curves?Question 2
What does setting
kde=True inside sns.histplot() do?Question 3
What does an ECDF (Empirical Cumulative Distribution Function) plot show on its y-axis?
Question 4
What is the primary advantage of
kdeplot over a traditional histogram?Question 5
In
sns.kdeplot(data=df, x='Salary', hue='Gender'), what does Seaborn render?Next Lesson
Categorical Plots: boxplot, violinplot, and countplot
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
Related Lessons
| Previous Lesson | Next Lesson |
|---|---|
| Seaborn Themes, Palettes & Aesthetics | Categorical Plots: boxplot, violinplot, and countplot |
Practice Quiz
Test your understanding of this lesson with 5 questions. Each question has one correct answer.