How to Find and Calculate Class Width on a Histogram

Class width is the difference between the upper and lower boundary of any single bar on a histogram. If a bar spans from 10 to 20 on the horizontal axis, the class width is 10. Finding it takes seconds when you’re reading a histogram, and only slightly longer when you’re building one from raw data.

Reading Class Width From an Existing Histogram

Look at the horizontal axis (x-axis). Each bar sits between two values. The class width is simply the distance between where one bar starts and where it ends. Pick any bar, subtract the left boundary from the right boundary, and you have your answer.

For example, if a bar stretches from 20 to 30 on the x-axis, the class width is 30 minus 20, which equals 10. In most histograms every bar has the same width, so you only need to check one. If the bars look like they vary in size, measure each one individually, because you’re dealing with an unequal-width histogram (more on that below).

Calculating Class Width From Raw Data

When you’re building a histogram from scratch, you choose the class width yourself. The standard process has three steps:

  • Find the range. Subtract the smallest value in your data set from the largest. If your data runs from 12 to 87, the range is 75.
  • Pick the number of classes. Most introductory statistics courses use between 5 and 20 classes. A common guideline called Sturges’ Rule sets the number of classes equal to 1 + log₂(n), where n is the number of data points. For 100 data points, that gives about 7 or 8 classes.
  • Divide and round up. Divide the range by the number of classes, then always round up to the next convenient number. If 75 ÷ 8 = 9.375, your class width becomes 10. Even if the result is already a whole number, round up to the next whole number. A range of 80 divided by 8 classes gives exactly 10, so you’d round up to 11.

That rounding-up rule trips people up because it’s the opposite of normal rounding. The reason is practical: rounding down or rounding to the nearest number can leave your last class too short to contain the maximum value. Rounding up guarantees every data point fits inside the classes you create.

Class Limits vs. Class Boundaries

This distinction matters because it changes the numbers you subtract. Class limits are the smallest and largest actual data values that belong in each group. Class boundaries are the values that physically separate one bar from the next on the histogram, typically sitting halfway between adjacent class limits.

Consider a class with limits of 10 to 14. The next class starts at 15. The boundary between them is 14.5. So the class boundaries are 9.5 to 14.5, and the true class width is 14.5 minus 9.5, which equals 5. Using the class limits (14 minus 10) gives you 4, which is off by one. When you’re reading a well-labeled histogram, the axis usually shows boundaries, so a simple subtraction gives the correct width. When you’re working from a frequency table that shows class limits, add 0.5 to the upper limit and subtract 0.5 from the lower limit to get the boundaries first, then subtract.

Here’s a quick reference using real class groupings:

  • Class limits 10–14: Boundaries are 9.5–14.5. Width = 5.
  • Class limits 15–19: Boundaries are 14.5–19.5. Width = 5.
  • Class limits 20–24: Boundaries are 19.5–24.5. Width = 5.

Notice every class has the same width. That’s the goal when you set up a standard histogram.

How Class Width Works in Unequal-Width Histograms

Not all histograms use bars of the same size. When class widths vary, the histogram has to adjust so wider bars don’t visually exaggerate the data. In these cases, the y-axis shows frequency density instead of plain frequency. Frequency density is calculated by dividing the frequency (the count of data points in that class) by the class width.

This means the area of each bar, not its height, represents how many data points fall in that range. A bar that’s twice as wide but has the same frequency as a narrow bar will be drawn half as tall, keeping the areas proportional to the actual counts. This is the key difference between a histogram and a bar chart: in a histogram, area carries the meaning.

To find the class width in an unequal-width histogram, you measure each bar individually along the x-axis. If one bar spans from 0 to 10 and the next spans from 10 to 25, their class widths are 10 and 15 respectively. To recover the actual frequency from a bar, multiply its height (frequency density) by its width.

Choosing the Right Number of Classes

Class width and number of classes are directly linked. More classes means narrower bars. Fewer classes means wider bars. Too many classes and your histogram looks jagged and hard to read. Too few and it smooths over patterns in the data.

Sturges’ Rule (1 + log₂n) works well for data sets that are roughly bell-shaped and have fewer than about 200 points. For larger data sets, the square root of n is a simpler starting point. With 400 data points, that gives 20 classes. These are guidelines, not rules. If the resulting class width is an awkward number like 7.3, it’s perfectly fine to adjust to 7 or 8 for cleaner boundaries.

The best approach is to try a few different widths and see which histogram reveals the shape of your data most clearly. The “correct” class width is the one that lets you see the distribution without hiding important features or creating misleading gaps.