Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 37 ยท Collecting and Displaying Data

Histograms and Grouped Data

Learn to draw histograms for continuous data, use frequency density for unequal class widths, and read the shape of a distribution, with Python examples.

A histogram displays continuous data. It looks like a bar chart, but there is a key difference: the bars touch, because the classes run on from each other along a continuous number line. The shape of a histogram tells you how the data are distributed: where most values sit, how spread out they are, and whether there are unusual values.

Equal class widths

When every class has the same width, the height of each bar is simply the frequency.

Heights of 30 students in classes of width 10 cm:

Height h (cm) Frequency
140 โ‰ค h < 150 3
150 โ‰ค h < 160 9
160 โ‰ค h < 170 10
170 โ‰ค h < 180 7
180 โ‰ค h < 190 1

The horizontal axis is a continuous scale with labeled boundaries. The vertical axis shows frequency.

Python A histogram with equal class widths

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Unequal class widths: frequency density

Sometimes you group some parts of the range more coarsely, for example when data are scarce at the high end. If you plotted raw frequency, a wide class would look too tall. The fix is to plot frequency density:

frequency density = frequency รท class width

Then the area of each bar (width ร— height) equals the frequency. Areas, not heights, represent counts.

Example: time spent on a website, in minutes.

Time t (min) Frequency Class width Frequency density
0 โ‰ค t < 5 10 5 2.0
5 โ‰ค t < 10 20 5 4.0
10 โ‰ค t < 20 18 10 1.8
20 โ‰ค t < 40 12 20 0.6

Here the last bar has height 0.6 but width 20, so its area is 0.6 ร— 20 = 12, which is the frequency.

Python Frequency density with unequal classes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

If a histogram axis is labeled "frequency density" you can recover a frequency by multiplying the bar's height by its width.

Reading the shape

The outline of a histogram is called the distribution. Common shapes:

  • Symmetric: left and right halves mirror each other, with a peak in the middle. Heights of adults often look like this.
  • Right-skewed (positive skew): a long tail to the right. Incomes and waiting times are typical.
  • Left-skewed (negative skew): a long tail to the left. Scores on an easy exam may look like this.
  • Bimodal: two peaks, often a sign of two mixed groups.
  • Uniform: bars about the same height.
flowchart LR
  A["Symmetric<br/>mean โ‰ˆ median"] --- B["Right-skewed<br/>mean > median"] --- C["Left-skewed<br/>mean < median"]

Skew and the relation between mean and median (a typical pattern, not a law).

Python Compare shapes of distributions

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Choosing classes

Too few classes hide the pattern; too many make a jagged mess. For roughly 30 to 100 observations, 5 to 8 classes is a good start. Try several and see which tells the clearest story.

Histogram or bar chart?

Bar chart Histogram
Categorical or discrete data Continuous (or grouped) data
Bars separated Bars touch
Bar height = frequency Equal widths: height = frequency; unequal: area = frequency

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. A class has frequency 24 and width 8. What is the frequency density?

    24 รท 8 = 3.
  2. 2. In a histogram with unequal class widths, what represents the frequency?

    Frequency density times class width gives the frequency, which is the bar's area.
  3. 3. A histogram has a long tail on the right. It is

    The direction of the long tail names the skew.
  4. 4. Why do histogram bars touch each other?

    The upper boundary of one class is the lower boundary of the next, on a continuous scale.

Summary

  • Histograms show continuous data with touching bars.
  • With equal widths, height is the frequency; with unequal widths, plot frequency density (frequency รท width) so that area equals frequency.
  • The shape (symmetric, skewed, bimodal, uniform) tells you the story of the data.
  • Pick enough classes to show the pattern without noise.

Next: Stem-and-Leaf Diagrams and Line Graphs