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
ax.hist(data, bins=30) # 30 binsax.hist(data, bins=30, density=True) # normalise to a probability densityax.hist([a, b], bins=20, label=["A", "B"]) # overlaid groups
The bin count matters
Key takeaways
- 01A histogram shows the distribution of one numeric variable via binned counts.
- 02It reveals shape: clusters, spread and skew.
- 03The bins count changes the picture — try several; too few or too many mislead.
- 04density=True normalises to a probability density.
