Skip to main content
Albero Academy

Histograms

Show the distribution of a single numeric variable.

Core Plot Types8 min

A histogram shows the distribution of one numeric variable by dividing it into bins and counting how many values fall in each. It reveals the shape — where data clusters, its spread, its skew.

ax.hist

binning data
ax.hist(data, bins=30) # 30 bins
ax.hist(data, bins=30, density=True) # normalise to a probability density
ax.hist([a, b], bins=20, label=["A", "B"]) # overlaid groups

The bin count matters

Key takeaways

  1. 01A histogram shows the distribution of one numeric variable via binned counts.
  2. 02It reveals shape: clusters, spread and skew.
  3. 03The bins count changes the picture — try several; too few or too many mislead.
  4. 04density=True normalises to a probability density.

Finished this chapter?

Mark it complete to track your progress through Matplotlib.