What Is Bin Width in a Histogram and Why It Matters

Bin width is the size of each interval that groups your data in a histogram. If a histogram shows test scores in groups of 0–9, 10–19, 20–29, and so on, the bin width is 10. It determines how “zoomed in” or “zoomed out” your histogram looks, and choosing the right one can mean the difference between spotting a meaningful pattern and staring at noise.

How Bin Width Works

A histogram takes continuous data (like heights, prices, or response times) and sorts every value into equally spaced intervals called bins. The bin width is simply the range each bin covers. If you have exam scores from 0 to 100 and you set a bin width of 10, you get 10 bins. Set it to 5 and you get 20 narrower bins showing more detail.

The basic relationship is straightforward: divide the range of your data (highest value minus lowest value) by the number of bins, and you get the bin width. Or work it the other way: pick a bin width first, and the number of bins follows. One detail that trips people up is counting. A bin labeled “0–49” actually has a width of 50, because it includes 50 possible whole-number values (0 through 49). The width is measured by the span of the interval, not the labels at its edges.

Why Bin Width Matters

Too wide, and your bins merge distinct groups together. Imagine plotting the ages of everyone at a school using a bin width of 30 years. Students and teachers would land in the same bin, hiding a pattern that’s obvious in real life. Too narrow, and each bin holds so few data points that the histogram becomes a jagged mess of spikes, making it hard to see any overall shape.

The right bin width reveals the underlying distribution of your data: whether it’s bell-shaped, skewed to one side, or has multiple peaks. This is why picking a good bin width isn’t just cosmetic. It directly affects the conclusions you draw.

Common Rules for Choosing Bin Width

You don’t have to guess. Statisticians have developed several formulas that calculate a reasonable bin width from your data’s properties. Each one makes slightly different assumptions.

Sturges’ Rule

The simplest approach. You calculate the number of bins as 1 + log₂(n), where n is how many data points you have. With 100 observations, that gives you about 7.6, so you’d round to 8 bins and divide your data range by 8 to get the width. Sturges’ rule works fine for moderate sample sizes (under about 200 data points), but it consistently produces bins that are too wide for larger datasets. The histogram looks overly smooth, hiding real features in the data.

Scott’s Rule

This formula sets the bin width proportional to the standard deviation of your data and inversely proportional to the cube root of the sample size. In plain terms: the more spread out your data, the wider the bins; the more data points you have, the narrower the bins. Scott’s rule is designed for data that roughly follows a bell curve, and it minimizes the overall estimation error when that assumption holds. It’s popular enough that Microsoft Excel uses it as the default algorithm when you create a histogram.

Freedman-Diaconis Rule

This one replaces standard deviation with the interquartile range (the span of the middle 50% of your data) and uses the formula: width = 2 × IQR × n^(−1/3). The interquartile range is less sensitive to extreme outliers than the standard deviation, so the Freedman-Diaconis rule is more robust when your data has a few unusually large or small values. If your dataset is skewed or has heavy tails, this rule generally gives you a more useful histogram than Scott’s rule.

How to Calculate Bin Width by Hand

Say you collected 64 measurements ranging from 12 to 98. Using Sturges’ rule, the number of bins is 1 + log₂(64) = 7. The range is 98 − 12 = 86. Divide 86 by 7 and you get a bin width of about 12.3. You’d typically round to a clean number like 12 or 13, depending on what makes the axis labels easy to read.

For Scott’s rule or Freedman-Diaconis, you’d need to know your data’s standard deviation or interquartile range first. Most spreadsheet and statistics software will compute these for you, which is why in practice people let the software pick the initial bin width and then adjust manually if the histogram doesn’t look right.

Adjusting Bin Width in Software

Excel defaults to Scott’s rule when you insert a histogram chart, labeling this option “Automatic” in the axis settings. You can override it by typing in a specific bin width or specifying the number of bins. Google Sheets, Python’s matplotlib, and R’s ggplot2 all let you set the bin width directly or choose from the rules described above.

No single formula works perfectly for every dataset. The best approach is to start with an automatic rule, then widen or narrow the bins to see if important features appear or disappear. If a second peak shows up when you narrow the bins, it might reflect a real subgroup in your data. If it vanishes with a small change, it’s probably noise.

Equal-Width vs. Equal-Count Bins

Everything above assumes equal-width bins, where every interval spans the same range. There’s an alternative: equal-count bins, where each bin holds the same number of data points. In that setup, bin widths vary. Bins in dense regions of the data are narrow, and bins in sparse regions are wide.

Equal-count histograms are useful when you have data that’s heavily concentrated in one area with a long tail stretching out. A salary distribution, for example, might have most values clustered between $30,000 and $80,000 but a thin tail extending past $500,000. Equal-width bins would either cram most of the detail into a couple of bars or require dozens of nearly empty bars in the upper range. Variable-width bins adapt to the data’s density, giving you a clearer picture across the entire range. The tradeoff is that the heights of the bars no longer directly represent counts; you need to use density (height × width) to compare bars fairly.