Tutorials › Introduction to Statistics › Worked Workshop on Histograms and Boxplots

Graphs for Quantitative Data · Tutorial 145 of 996

Worked Workshop on Histograms and Boxplots

Learn to construct and interpret a histogram and a modified boxplot for the same daily step-count data, and explain how their summaries differ.

Beginner 10 min read

What You'll Learn

  • Organize daily step counts into explicit histogram intervals and calculate their frequencies.
  • Choose bar heights correctly for equal-width and unequal-width histogram bins.
  • Construct a modified boxplot from a stated five-number summary.
  • Describe the shape, center, spread, and unusual values visible in each display.
  • Explain which features one graph preserves that the other conceals.

One Data Set, Two Useful Views

A histogram and a boxplot can both summarize a set of quantitative measurements, but they do not show the same things. A histogram groups observations into intervals, making the overall pattern of frequencies visible. A boxplot compresses the data into a five-number summary and, in its modified form, marks observations beyond the whiskers separately. Looking at both can help describe a distribution without mistaking a compact summary for a complete picture.

Suppose a fictional student records daily step counts for 12 days. The counts below are hypothetical, and are measured in steps:

$$ 3{,}200,\ 4{,}100,\ 4{,}500,\ 5{,}200,\ 5{,}900,\ 6{,}500,\ 7{,}200,\ 7{,}800,\ 8{,}400,\ 9{,}300,\ 11{,}200,\ 16{,}800 $$

The values are already in increasing order. We will use the same observations for both displays, so that the differences between the graphs come from how each organizes information—not from a difference in the data.

Building the Histogram

Definition: A histogram displays quantitative observations using adjacent bars over intervals, or bins, along a number line. Each observation is counted in one bin. For equal-width bins, bar height may represent frequency. For unequal-width bins, bar height is frequency density—the bin frequency divided by its width—so that each bar’s area is proportional to the frequency it represents.

Before counting, choose bin boundaries that cover the data and state which boundary values belong to which bin. Here we use six equal-width bins of 3,000 steps each, starting at 0. The intervals are left-closed and right-open: for example, \([3{,}000,6{,}000)\) includes 3,000 but not 6,000. This convention prevents a value on a boundary from being counted twice.

Worked Example: Counting Step Counts in Histogram Bins

Count the 12 daily step totals in the selected intervals. The first interval, \([0,3{,}000)\), contains no observations. The interval \([3{,}000,6{,}000)\) contains 3,200, 4,100, 4,500, 5,200, and 5,900, so its frequency is 5. Applying the same rule to the remaining intervals gives:

Interval (steps)Values in intervalFrequency
[0, 3,000)None0
[3,000, 6,000)3,200; 4,100; 4,500; 5,200; 5,9005
[6,000, 9,000)6,500; 7,200; 7,800; 8,4004
[9,000, 12,000)9,300; 11,2002
[12,000, 15,000)None0
[15,000, 18,000)16,8001

The frequencies add to \(0+5+4+2+0+1=12\), matching the number of observed days. Because all bins have width 3,000 steps, a frequency-height histogram can use the frequencies 0, 5, 4, 2, 0, and 1 as the respective bar heights. The bars touch because the bins cover adjoining intervals; bins with frequency zero have no visible bar.

Why Bar Height Depends on Bin Width

With unequal-width bins, a bar’s height must account for how wide the interval is. Otherwise, a wider interval could look more important simply because it covers more of the horizontal axis. For unequal-width bins, use frequency density as the height:

$$ \text{frequency density}=\frac{\text{frequency}}{\text{bin width}} $$

The product of that height and the bin width is the frequency. Therefore, the area of the bar represents the number of observations in the bin. When bins have equal width, frequencies and frequency densities differ by the same constant factor, so frequency itself can be used for the heights.

Worked Example: Comparing Heights for Unequal Bin Widths

Imagine using one bin from 0 to 3,000 steps and another from 3,000 to 9,000 steps for the same data. These bins are hypothetical and are not taken from the displayed data. Suppose the first bin has frequency 4 and the second also has frequency 4. The first bin has width 3,000 steps and the second has width 6,000 steps.

For the first bin, frequency density is \(4/3{,}000=0.001333\) observations per step. For the second, it is \(4/6{,}000=0.000667\) observations per step. The second bar should be half as tall because it is twice as wide but represents the same number of observations.

The bar areas are \(0.001333\times3{,}000\approx4\) observations and \(0.000667\times6{,}000\approx4\) observations. Thus, both bars represent four observations by area. This example illustrates the rule; the actual histogram for the 12 daily counts above uses equal-width bins.

Constructing a Modified Boxplot

A boxplot is built from the five-number summary: the minimum, first quartile, median, third quartile, and maximum. The box extends from the first quartile to the third quartile, with a line at the median. In a modified boxplot, the whiskers extend to the most extreme observations that are not flagged as potential outliers; any flagged observations are shown separately.

For this worked data set, quartiles are calculated by splitting the ordered observations into equal lower and upper halves and taking the median of each half. This states the method used for the example; quartile conventions can vary. A modified boxplot commonly flags observations outside the inner fences, which are \(Q_1-1.5\,IQR\) and \(Q_3+1.5\,IQR\), where \(IQR=Q_3-Q_1\). Flagging is a plotting rule, not a claim that a value is erroneous.

Worked Example: Finding the Boxplot Features

There are 12 ordered step counts. The median is the average of the sixth and seventh values:

$$ \text{Median}=\frac{6{,}500+7{,}200}{2}=6{,}850\text{ steps} $$

The lower half is 3,200, 4,100, 4,500, 5,200, 5,900, and 6,500. Its middle two values are 4,500 and 5,200, so \(Q_1=(4{,}500+5{,}200)/2=4{,}850\) steps. The upper half is 7,200, 7,800, 8,400, 9,300, 11,200, and 16,800. Its middle two values are 8,400 and 9,300, so \(Q_3=(8{,}400+9{,}300)/2=8{,}850\) steps.

The interquartile range is \(8{,}850-4{,}850=4{,}000\) steps. The inner fences are:

$$ 4{,}850-1.5(4{,}000)=-1{,}150,\qquad 8{,}850+1.5(4{,}000)=14{,}850 $$

No observation is below \(-1{,}150\), while 16,800 is above 14,850. Thus, the five-number summary is 3,200, 4,850, 6,850, 8,850, and 16,800 steps, but the modified boxplot marks 16,800 separately. The box runs from 4,850 to 8,850, with its median line at 6,850. Its lower whisker reaches 3,200, and its upper whisker reaches 11,200, the most extreme observation still within the upper fence. A separate point represents 16,800.

Describing and Comparing the Displays

A useful description names the variable and its units, then reports visible features rather than relying on a graph name alone. The histogram of these 12 days has its largest frequency in the 3,000-to-6,000-step bin, followed by 6,000 to 9,000 steps. Frequencies decline across the higher bins, and one day lies in the 15,000-to-18,000-step bin. There is a gap from 12,000 to 15,000 steps. These features suggest a longer tail toward higher step counts, but the histogram’s exact appearance depends on the chosen bin boundaries and widths.

The modified boxplot shows that the middle half of daily counts extends from 4,850 to 8,850 steps, with a median of 6,850 steps. Its upper whisker is longer than its lower whisker, and it marks 16,800 steps as a potential outlier under the stated 1.5-IQR rule. Neither display proves that the unusually high count is an error or explains why it occurred.

Key distinction: A histogram shows how observations are distributed among chosen intervals, so it can reveal clusters, gaps, and changes in frequency across the scale. A boxplot highlights the median, quartiles, overall whisker reach, and any flagged points, but it does not show the detailed frequency pattern within the box or along the whiskers.

Worked Example: Explaining What the Boxplot Hides

In the histogram, four days fall between 6,000 and 9,000 steps, and two fall between 9,000 and 12,000. The boxplot does not show those bin counts. It shows only that the median is 6,850 and that the middle half stretches from 4,850 to 8,850 steps. In particular, the box does not tell us whether the four central observations are evenly spread or clustered near one end.

Conversely, the histogram places each value into a bin, so it shows the empty 12,000-to-15,000 interval. The boxplot’s whisker ending at 11,200 and separate point at 16,800 indicate an unusual high value relative to the fence rule, but do not display every count between those locations. The two displays complement one another: neither is a more detailed version of the other.

This difference matters when describing data. A boxplot is compact and useful for comparing centers, middle-half spreads, and flagged points across groups. A histogram is useful when the shape or concentration of observations is important. When possible, inspect both rather than assuming that a five-number summary fully describes the distribution.

Common Mistakes

  • Using frequency as bar height for unequal-width bins. Equal frequencies do not imply equal heights when bin widths differ. Use frequency density so the bar areas represent frequencies.
  • Leaving gaps between histogram bars. The bars represent adjacent intervals on a quantitative scale, so they ordinarily touch. A zero-frequency interval has no visible bar, but the scale still includes that interval.
  • Calling a flagged observation an error. The fence rule identifies a value as unusual relative to the rest of the sample; it does not establish that the value was recorded incorrectly.
  • Claiming a boxplot reveals the full shape. The boxplot preserves selected summaries but hides the detailed distribution of observations within its sections. Check a histogram when clusters or gaps matter.
  • Ignoring bin choices. A different set of boundaries can change the visible histogram pattern. State the intervals and avoid treating one binning as the only possible view.

Check Your Understanding

Use the ideas in this tutorial to answer the following questions.

  1. For equal-width histogram bins, what can be used as bar height, and what should the bar height represent when bins have unequal widths?
  2. Why do the frequencies in the worked histogram need to add to 12?
  3. Using the stated quartile method, why does the median of the step counts equal 6,850 steps?
  4. What does the separately plotted 16,800-step observation mean in the modified boxplot, and what does it not establish?
  5. Name one feature visible in the histogram but not shown in equivalent detail by the boxplot.