Sub topic 12
Comparing Two Boxplots
This chapter assumes you can already read a five-number summary off a single boxplot: minimum, Q1, median, Q3, and maximum. It also assumes you know that the interquartile range (IQR) is Q3 minus Q1. Here you will put two boxplots side by side and decide what the pictures do and do not tell you.
What a Side-by-Side Comparison Covers
A boxplot compresses a data set into five numbers. Two boxplots drawn on the same axis let you compare those numbers directly. Every comparison question comes down to four features:
- Center: compare the medians. The group with the higher median has a higher middle value.
- Spread of the middle half: compare the IQRs, which are the box lengths.
- Overall spread: compare the ranges, which are the distances from the lowest to the highest point.
- Shape and outliers: look at where the median sits inside the box, how long each whisker is, and whether any points are plotted separately.
A boxplot does not show the mean, the number of data values, or the individual values. It also does not show whether the data has clusters or gaps. Any conclusion about those things is unsupported unless the problem gives extra information.
A Reliable Method
Follow the same steps for every pair of boxplots.
- Check that both plots use the same axis. If the scales differ, convert before you compare.
- Read the five numbers off each plot. Write them down instead of judging by eye.
- Compute each range and IQR.
- Compare centers, then spreads, then shape.
- Match your result to the exact wording of the question. Decide whether it asks about the middle half, the whole data set, or a percent of the data.
Worked Example: Two Classes
Suppose two classes took the same exam. Their five-number summaries are:
| Statistic | Class A | Class B |
|---|---|---|
| Minimum | 52 | 40 |
| Q1 | 64 | 66 |
| Median | 72 | 74 |
| Q3 | 80 | 78 |
| Maximum | 94 | 98 |
The code below computes the quantities you would work out by hand. It also checks the 1.5 x IQR fences for each class.
def summarize(minimum, q1, median, q3, maximum):
return {
"min": minimum,
"q1": q1,
"median": median,
"q3": q3,
"max": maximum,
"range": maximum - minimum,
"iqr": q3 - q1,
"lower_box": median - q1,
"upper_box": q3 - median,
}
def fences(q1, q3):
iqr = q3 - q1
return q1 - 1.5 * iqr, q3 + 1.5 * iqr
class_a = summarize(52, 64, 72, 80, 94)
class_b = summarize(40, 66, 74, 78, 98)
for key in class_a:
print(key, class_a[key], class_b[key])
for name, s in [("A", class_a), ("B", class_b)]:
low, high = fences(s["q1"], s["q3"])
print(name, low, high, s["min"] < low, s["max"] > high)The first loop prints these lines:
min 52 40
q1 64 66
median 72 74
q3 80 78
max 94 98
range 42 58
iqr 16 12
lower_box 8 8
upper_box 8 4The second loop prints:
A 40.0 104.0 False False
B 48.0 96.0 True TrueReading the Results
Center. Class B's median is 74 and Class A's is 72. Class B has the slightly higher middle score.
Middle-half spread. Class A's IQR is 16 and Class B's is 12. Class B's middle 50% of scores is more tightly grouped.
Overall spread. Class A's range is 42 and Class B's is 58. Class B has the larger range even though its IQR is smaller. The extreme scores, not the typical ones, stretch Class B's range. The IQR is the better measure of consistency here.
Shape. Class A's median is 8 above Q1 and 8 below Q3, so its box is split evenly. Class B's median is 8 above Q1 but only 4 below Q3. The upper part of Class B's box is half as long as the lower part. The scores between the median and Q3 are packed more closely than those between Q1 and the median.
Outliers. Under the 1.5 x IQR convention, Class B's fences are 48 and 96. Its minimum of 40 and its maximum of 98 both fall outside, so a plot that uses this rule would draw them as separate points. The whiskers would then stop at the most extreme values inside the fences. Class A's values all sit within its fences of 40 and 104. This changes the comparison. Once the extreme points are set aside, Class B's whiskers are shorter than the range suggests.
Estimating Percents from Quartiles
Quartile boundaries let you bound the share of data above or below a value. Each section of the boxplot holds about 25% of the data. These are the reference points:
| Position | Percent of data at or below |
|---|---|
| Minimum | about 0% |
| Q1 | about 25% |
| Median | about 50% |
| Q3 | about 75% |
| Maximum | about 100% |
If a value lies between two reference points, its percentile lies between the matching percents. For Class B, a score of 70 lies between Q1 (66) and the median (74). About 25% to 50% of Class B scored at or below 70. So 50% to 75% scored above 70.
Compare this with Class A. A score of 70 lies between Class A's Q1 (64) and median (72). Again, 25% to 50% of Class A scored at or below 70. A boxplot gives only ranges like this. It cannot give an exact percent, because it does not show how values are spread inside each section.
You can also compare across groups. Class B's Q1 is 66, so about 75% of Class B scored at least 66. Class A's Q1 is 64, so about 75% of Class A scored at least 64. Judged by the bottom quarter, Class B's weakest typical students scored a little higher.
Which Claims Are Supported?
Practice sorting statements into supported and unsupported ones. Using the two classes above:
| Statement | Supported? | Reason |
|---|---|---|
| Class B has the higher median. | Yes | 74 is greater than 72. |
| Class B's scores are more consistent in the middle. | Yes | Its IQR of 12 is less than 16. |
| Class B has more students. | No | Boxplots do not show counts. |
| Class B's mean is higher. | No | The mean is not shown, and it can differ from the median. |
| At least half of Class A scored 72 or higher. | Yes | The median is 72. |
| The highest score in Class B is above every Class A score. | Yes | 98 is greater than 94. |
| Every student in Class B outscored every student in Class A. | No | The boxes overlap, so many scores are shared. |
Common Pitfalls
- Treating box length as data count. A long box means the middle 25% to 75% of the data is spread out. It does not mean more values are there. Each section holds about the same share of the data, whatever its length.
- Equating a higher median with "mostly higher." Two groups can have similar medians and very different spreads. A higher median says only that the middle value is higher.
- Judging consistency by the range. One extreme value controls the range. For the typical spread, compare IQRs.
- Overreading overlap. Overlapping boxes do not show that two groups are the same. Separate boxes show that the middle halves do not overlap. Neither case proves anything about individual values.
- Ignoring the axis. Check that both plots share one scale. A plot that looks wider on a compressed axis may have a smaller range.
- Treating a quartile as a percent. Q1 is a value in the data, such as 64. It is not "25." The percent attached to Q1 is about 25% of the data lying at or below it.
- Reading the median as the center of the box. Where the median sits inside the box tells you about shape. If it sits near Q3, the upper part of the middle half is more tightly packed than the lower part.
GRE Strategy
Quantitative comparison questions often name two quantities, such as the IQR of Group A and the IQR of Group B. Work this way:
- Read the five numbers for each group, or estimate them from the scale. If the axis marks are coarse, estimate and look at whether the gap is clear.
- Compute only the quantity named. Do not compute the range if the question asks about the IQR.
- Be careful with "cannot be determined." If the comparison depends on a quantity the plot does not show, such as a mean or a count, that answer may be correct.
- Use the quartile percents. When a question asks for the least or greatest possible percent of data in a region, reason from the 25% sections.
- Check outliers last. If the problem states the 1.5 x IQR rule, compute the fences before you decide where a whisker ends.
Exercise
Boxplot X has minimum 10, Q1 20, median 30, Q3 50, maximum 90. Boxplot Y has minimum 15, Q1 25, median 35, Q3 45, maximum 55. Which has the larger median, which has the larger IQR, and which has the larger range?
Show answer
Median: Y is larger (35 versus 30). IQR: X is larger (50 - 20 = 30 versus 45 - 25 = 20). Range: X is larger (90 - 10 = 80 versus 55 - 15 = 40).
Exercise
A student says, "Group P's box is twice as long as Group Q's box, so Group P has twice as many data values." Explain what is wrong.
Show answer
The length of a box shows spread, not count. Each section of a boxplot holds about 25% of its own group's data, so the middle half of each group is the same share whatever the group size or box length. Boxplots do not show how many values a group contains.
Exercise
In Class B above (minimum 40, Q1 66, median 74, Q3 78, maximum 98), a student scored 70. Between what percents does the share of Class B scoring at or below 70 lie?
Show answer
Between 25% and 50%. The score 70 lies between Q1 (66, about the 25th percentile) and the median (74, about the 50th percentile).