AtomLearnAtomLearn
DashboardGoalsPathAchievementsReviewSign In
Data VisualizationNot Started

Histograms

Visualize the distribution of a single continuous variable

0%
Knowledge0%
Learn & Drill
Fluency0%
Drill & Speed
Retention0%
Mastery & Review
Confidence0%
All modes
Practice

Free tier: read the explanation here. Upgrade to Pro for Drills, Speed challenges & Mastery badges.

Upgrade
Knowledge
Fluency
Retention

Knowledge Debt detected

You can study this freely — but your score may plateau if these foundations have gaps. The Mastery badge requires them to be solid.

Explanation

A histogram divides continuous data into bins (ranges) and shows the count (or frequency) of values in each bin.

python
import numpy as np
data = np.random.normal(loc=170, scale=10, size=1000)  # heights in cm

fig, ax = plt.subplots()
ax.hist(data, bins=30, color='steelblue', edgecolor='white', alpha=0.7)
ax.set_xlabel('Height (cm)')
ax.set_ylabel('Count')
ax.set_title('Distribution of Heights')
plt.show()

Key parameters:

  • bins — number of bins (or list of bin edges). Default is 10.
  • alpha — transparency (0=invisible, 1=solid) — useful for overlapping histograms
  • density=True — normalize so area = 1 (shows probability density)
  • edgecolor — color of bin borders

Multiple distributions:

python ax.hist(group_a, bins=20, alpha=0.5, label='Group A') ax.hist(group_b, bins=20, alpha=0.5, label='Group B') ax.legend()

Choosing bins: Too few → loses detail. Too many → noisy. Rule of thumb: √n bins for n data points.

Examples

Overlapping histograms

alpha<1 makes overlapping histograms visible

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
group_a = np.random.normal(165, 8, 500)  # women heights
group_b = np.random.normal(178, 9, 500)  # men heights

fig, ax = plt.subplots(figsize=(8,4))
ax.hist(group_a, bins=30, alpha=0.5, label='Women', color='pink')
ax.hist(group_b, bins=30, alpha=0.5, label='Men', color='skyblue')
ax.set_xlabel('Height (cm)')
ax.set_title('Height Distribution by Group')
ax.legend()
plt.show()

How well did you understand this?

Next in Data Visualization

Scatter Plots

Continue