11/13
Statistical Plots & Distributions Β· Page 1 of 1

Distribution Visualization

Statistical Plots & Distributions

Histogram with KDE (Kernel Density Estimation)

Overlaying a smooth curve on a histogram shows the underlying distribution:

import matplotlib.pyplot as plt
import seaborn as sns

fig, ax = plt.subplots()
sns.histplot(data, kde=True, stat='density', ax=ax)
ax.set_title('Distribution with KDE')

Violin Plots

Combine a box plot and KDE to show full distribution shape:

sns.violinplot(data=df, x='category', y='value')

Shows:

  • Box inside = 25th-75th percentile
  • Line inside box = median
  • Outer curve = full distribution (KDE)

Q-Q Plot (Quantile-Quantile)

Check if data is normally distributed:

from scipy import stats
fig, ax = plt.subplots()
stats.probplot(data, dist="norm", plot=ax)
ax.set_title('Q-Q Plot: Testing Normality')

Perfect 45Β° line = normally distributed data.

Box Plot

Shows outliers, quartiles, and median at a glance:

ax.boxplot([group1, group2, group3], labels=['A', 'B', 'C'])

When to use: Histogram for single distributions, violin for comparing groups, box plot for spotting outliers.

main.py
Loading...
OUTPUT
β–ΆClick "Run Code" to execute…