Boxplots

箱线图

How do you draw a boxplot?

A box spans the quartiles with the median inside; whiskers extend to the extremes.

SkillKP000932

Sign in to read the whole lesson, with 1 interactive aid, 10 exercises

Sign in / Sign up

Mastery goals

  • Can draw a boxplot (horizontal or vertical) from the five-number summary
  • Can read the five-number summary from a boxplot
  • Can compare two data sets with side-by-side boxplots

To make the shape of a distribution visible at a glance, take the three quartiles plus the smallest and largest values — five numbers in all — and draw a boxplot (box-and-whisker plot). Take shop A's growth rates: in the middle is a rectangular "box", and a horizontal segment called a whisker sticks out on each side. The short vertical lines at the outer ends of the whiskers mark the smallest and the largest value; the left edge of the box marks the first quartile, the right edge the third quartile, and the line inside the box the second quartile (the median). How long the box is from left to right is the third quartile minus the first quartile, and this difference is called the interquartile range. Looking at a boxplot you can get a rough idea of how far the data stretch, how big the median is, which stretch most data crowd into, and whether the two sides are balanced.

In the same way we can draw the boxplot of shop B's growth rates. To compare the two shops' distributions, draw the two boxplots side by side in one figure; a boxplot can also be drawn vertically.

In the figure the two median lines almost line up, so the shops' medians are about the same; but shop A's box and whiskers are clearly longer than B's, so A's growth rates swing much more — the same conclusion we reached with the mean and variance. The boxplot reveals more besides, for example: shop B's distribution is more symmetric than A's (the median line is in the middle of the box); about a quarter of A's months have growth above B's largest, and about a third of A's months fall below B's smallest, and so on.

Summary To find the quartiles of a data set, first sort the data from smallest to largest, then work in two steps. Step 1: find the median of all the data; this is the second quartile. Step 2: the median splits the data into a left half and a right half; the median of the left half is the first quartile and the median of the right half is the third quartile. These three quartiles, together with the smallest and largest values, give a rough picture of how the data are distributed.

Example 1

Using the temperature data of Example 3 in Section 24.2, find the quartiles of the temperatures of cities A and B, draw their boxplots in one figure, and compare the temperatures of the two cities.

Solution: Arrange the temperatures (in ℃) of the two cities from smallest to largest:

A

B

Each city has data. City A's smallest temperature is , the largest is , and the three quartiles are

City B's smallest is , the largest is , and the three quartiles are

Draw the two cities' boxplots in one figure:

0510152025City ACity B
City A
Min
6
Q₁
8.5
Median
12.5
Q₃
18
Max
21
IQR
9.5
City B
Min
9
Q₁
10.5
Median
13
Q₃
15
Max
17
IQR
4.5
Boxplots of the temperatures of cities A and B (in ℃).

We see that the two cities' median temperatures are close, but city A's temperature fluctuates much more than B's: city A has times (about a third) with temperature above B's highest, ℃, and times (about a quarter) below B's lowest, ℃.

Related points

All points in this topic

Cite this page: Boxplots · KnowledgeTree (知识树), https://www.knowledgetree.world/en/kp/KP000932