A bin is one of the equal-width intervals a histogram splits the data range into, such as 60–70 or 70–80. Each bar's height is how many values fall in its bin, so the bin count (or, equivalently, the bin width) decides what the chart can show. The two are linked: bin width = (max − min) ÷ bin count.
Why bin count isn't a cosmetic setting
A histogram divides a variable's range into equal-width bins and counts how many values fall into each — but the same underlying data can look meaningfully different depending on how many bins that range is divided into. This isn't a rendering quirk; bin count genuinely changes what patterns are visible or hidden, which is why it's worth actively adjusting rather than accepting whatever default a tool picks.
Too few bins: hiding real structure
With very few, wide bins, distinct patterns get merged together — two genuinely separate peaks in the underlying data (a classic sign of two different subgroups mixed into one dataset) can blend into what looks like a single broad hump once the bins are wide enough to span both peaks. Under-binning doesn't just lose detail, it can actively mislead you into thinking a dataset is more uniform or unimodal than it really is.
Too many bins: manufacturing noise
With very many, narrow bins, individual random fluctuations in the data become visually prominent — the histogram starts to look jagged and irregular, with gaps and spikes that reflect small-sample noise rather than any real underlying pattern. Over-binning can make genuinely smooth, simple data look artificially complex and noisy.
The five standard rules
| Rule | Bin count k, or bin width h | Best for |
|---|---|---|
| Square root | k = √n | A quick default for any data |
| Sturges | k = 1 + log₂ n | Small, roughly normal data; R's default. Too few bins for large n |
| Rice | k = 2 · n^(1/3) | Larger datasets than Sturges handles well |
| Scott | h = 3.49 · σ · n^(−1/3) | Roughly normal data; Excel's automatic bins |
| Freedman-Diaconis | h = 2 · IQR · n^(−1/3) | Skewed data or outliers: IQR ignores the extremes |
n is the number of values, σ the standard deviation and IQR the interquartile range (Q3 − Q1). Scott and Freedman-Diaconis give a width; divide the range by it to get the count, and round up.
Worked example
200 exam scores from 0 to 100, with σ = 15 and IQR = 20:
- Square root: √200 = 14.1 → 15 bins
- Sturges: 1 + log₂ 200 = 8.6 → 9 bins
- Rice: 2 × 200^(1/3) = 11.7 → 12 bins
- Scott: h = 3.49 × 15 ÷ 200^(1/3) = 8.95, so 100 ÷ 8.95 → 12 bins
- Freedman-Diaconis: h = 2 × 20 ÷ 200^(1/3) = 6.84, so 100 ÷ 6.84 → 15 bins
The rules agree on roughly 9–15, which is the range worth trying. They drift apart as n grows: for 100,000 values Sturges still suggests 18 bins while Rice suggests 93 and √n 316. That is why Sturges is a poor choice for big datasets.
Whatever the rule says, treat it as a starting point and adjust while watching the shape, because the right number depends on the pattern you are trying to see. In practice, round the width to a readable number (5 or 10 points rather than 6.84) so the bin edges make sense to readers.
What your software does by default
| Tool | Default |
|---|---|
| Excel histogram chart (2016+) | Scott's rule ("Automatic"); change under Format Axis → Bins |
| Google Sheets | Its own automatic choice; set "Bucket size" to override |
matplotlib plt.hist |
10 bins, whatever the data |
NumPy bins='auto', seaborn histplot |
The larger of Sturges and Freedman-Diaconis |
R hist() |
Sturges |
matplotlib's fixed 10 is the one most likely to mislead: pass bins='auto' or bins='fd' instead.
What to look for as you adjust
- Does a single hump split into two as you add more bins? That's a real signal worth investigating — it may indicate two distinct subgroups in your data that a coarser view was hiding.
- Does the shape stay stable across a reasonable range of bin counts? That's a good sign the pattern you're seeing (skew, a clear peak, roughly uniform spread) is real structure, not an artifact of a specific bin choice.
- Does the histogram turn jagged and spiky only at very high bin counts? That's usually noise from small per-bin sample sizes, not genuine structure — back off to fewer bins.
Common mistakes
- Accepting a tool's default bin count without checking whether it obscures or reveals structure. Defaults are a reasonable starting guess, not a guarantee of the most informative view.
- Assuming more bins always means "more accurate" or "more detailed." Beyond a certain point, additional bins just add noise from small per-bin counts, not real information.
- Drawing conclusions from a single bin-count choice rather than checking whether the visible pattern holds up as you adjust the bin count up and down.
FAQ
What is a bin in a histogram?
One of the equal-width intervals the data range is divided into. A bin from 70 to 80 counts every value from 70 up to (but not including) 80, and its bar's height is that count.
How many bins should a histogram have?
Start with √n or a rule like Freedman-Diaconis (for 200 values, roughly 10–15), then adjust. Fewer bins show the overall shape; more show detail but also noise. If a feature appears only at one bin count, it is probably not real.
Is there a single correct number of histogram bins?
No — common formulas (square root rule, Sturges' formula) provide a reasonable starting point, but the genuinely useful approach is adjusting interactively and checking whether the pattern you see is stable across a range of bin counts.
Why does my histogram look different with more bins even though the data hasn't changed?
Because bin count controls resolution — finer bins reveal more detail (which can be real structure or just noise), while coarser bins smooth over detail (which can hide real structure or usefully simplify noise).
How do I know if what I'm seeing is real structure or just noise from too many bins?
Check whether the pattern holds up across a reasonable range of bin counts — a real feature (like two distinct peaks) tends to persist; noise artifacts tend to appear and disappear as you adjust the bin count slightly.
Adjust bin count interactively and explore any numeric column's distribution with the Histogram Generator — entirely in your browser.
Use the Statistics Calculator to summarize a dataset before interpreting it. For a related walkthrough, read EDA: The First Five Numbers to Check.