Course contentsShow
← Data Science
Lesson 1175 of 2,14530. Exploratory Data Analysis (EDA) ProcessFree lesson

Histograms for Distribution Shape

Using histograms to visualize frequency distributions and identify skewness, modality, and gaps.

Histograms for Distribution Shape

You'll learn how to use histograms to quickly visualize the shape, spread, and quirks of a numerical variable's distribution.

What Is a Histogram?

A histogram divides a numerical variable into bins (ranges) and displays the count or frequency of observations falling into each bin as bars. Think of it like sorting coins into jars labeled by their value ranges—the height of each jar shows how many coins landed there.

Unlike bar charts (which show categories), histograms reveal the shape of continuous data: where values cluster, how spread out they are, and whether the distribution is symmetric or lopsided.

What Histograms Reveal

Skewness

  • Right-skewed (positive skew): A long tail stretches to the right; most values cluster at the lower end (e.g., household income—many modest earners, few billionaires).
  • Left-skewed (negative skew): A long tail to the left; most values cluster high (e.g., test scores where most students do well).
  • Symmetric: Values distributed evenly around the center (e.g., heights in a population).

Modality

  • Unimodal: One clear peak (most common).
  • Bimodal: Two distinct peaks, suggesting two subgroups (e.g., adult and child heights mixed together).
  • Multimodal: Multiple peaks, indicating several subpopulations.

Gaps and Outliers

Histograms expose gaps (empty bins) that might signal data collection issues or natural separations, and outliers (isolated bars far from the main cluster).

Creating a Histogram

import pandas as pd
import matplotlib.pyplot as plt

# Example: ages in a dataset
ages = pd.Series([23, 25, 22, 45, 47, 50, 24, 26, 48, 52, 23, 22])

ages.hist(bins=5, edgecolor='black')
plt.xlabel('Age')
plt.ylabel('Frequency')
plt.title('Age Distribution')
plt.show()

Key Takeaway: Histograms transform raw numbers into visual stories about distribution shape—revealing skewness, modality, and unusual patterns at a glance.