Skip to content

Distribution Plots (displot, histplot)

Why distribution plots matter

Distribution plots answer:

  • What values are most common?
  • Is the data skewed?
  • Are there outliers?
  • Do groups behave differently?

histplothistplot (single plot)

histplot
import seaborn as sns
import matplotlib.pyplot as plt
 
values = [55, 60, 62, 63, 65, 67, 70, 72, 76, 80, 81, 85, 90, 92, 95]
 
plt.figure(figsize=(7, 4))
sns.histplot(values, bins=8, kde=False)
plt.title("Histogram")
plt.xlabel("Value")
plt.ylabel("Count")
plt.tight_layout()
plt.show()
histplot
import seaborn as sns
import matplotlib.pyplot as plt
 
values = [55, 60, 62, 63, 65, 67, 70, 72, 76, 80, 81, 85, 90, 92, 95]
 
plt.figure(figsize=(7, 4))
sns.histplot(values, bins=8, kde=False)
plt.title("Histogram")
plt.xlabel("Value")
plt.ylabel("Count")
plt.tight_layout()
plt.show()

Add KDE on top

histplot + kde
import seaborn as sns
import matplotlib.pyplot as plt
 
plt.figure(figsize=(7, 4))
sns.histplot(values, bins=8, kde=True)
plt.title("Histogram + KDE")
plt.tight_layout()
plt.show()
histplot + kde
import seaborn as sns
import matplotlib.pyplot as plt
 
plt.figure(figsize=(7, 4))
sns.histplot(values, bins=8, kde=True)
plt.title("Histogram + KDE")
plt.tight_layout()
plt.show()

displotdisplot (figure-level)

displotdisplot can create more complex plots and handles facets.

displot
import seaborn as sns
 
# Seaborn includes sample datasets
 
tips = sns.load_dataset("tips")
 
sns.displot(data=tips, x="total_bill", bins=20, kde=True)
displot
import seaborn as sns
 
# Seaborn includes sample datasets
 
tips = sns.load_dataset("tips")
 
sns.displot(data=tips, x="total_bill", bins=20, kde=True)

Compare distributions by group

Compare groups
import seaborn as sns
import matplotlib.pyplot as plt
 
tips = sns.load_dataset("tips")
 
plt.figure(figsize=(7, 4))
sns.histplot(data=tips, x="total_bill", hue="sex", bins=20, kde=True, element="step")
plt.title("Total bill distribution by sex")
plt.tight_layout()
plt.show()
Compare groups
import seaborn as sns
import matplotlib.pyplot as plt
 
tips = sns.load_dataset("tips")
 
plt.figure(figsize=(7, 4))
sns.histplot(data=tips, x="total_bill", hue="sex", bins=20, kde=True, element="step")
plt.title("Total bill distribution by sex")
plt.tight_layout()
plt.show()

Tips

  • Use the same bin settings when comparing groups.
  • KDE is a smooth estimate; it can hide small details.
  • For heavy outliers, consider log scaling.

If this helped you, consider buying me a coffee ☕

Buy me a coffee

Was this page helpful?

Let us know how we did