Sub topic 10
Drawing a Boxplot from Data
Assume you can order a data set, find its median and quartiles, and read a labeled number line. A boxplot is a graph that summarizes an ordered data set with five important values: the minimum, first quartile \(Q1\), median, third quartile \(Q3\), and maximum.
Build the Five-Number Summary
Start with the data in least-to-greatest order:
\[ 3,\ 5,\ 7,\ 8,\ 12,\ 13,\ 14,\ 18,\ 21 \]
The median is 12. Excluding the median, the lower half is \(3,5,7,8\), so \(Q1=(5+7)/2=6\). The upper half is \(13,14,18,21\), so \(Q3=(14+18)/2=16\).
The five-number summary is:
| Value | Number |
|---|---|
| Minimum | 3 |
| First quartile, \(Q_1\) | 6 |
| Median | 12 |
| Third quartile, \(Q_3\) | 16 |
| Maximum | 21 |
These values determine the main parts of the boxplot.
Draw the Box and Whiskers
Use a number line that includes every relevant value.
- Mark \(Q1=6\), the median \(=12\), and \(Q3=16\).
- Draw a box from 6 to 16.
- Draw a vertical line inside the box at 12.
- Draw a whisker from 6 to the minimum, 3.
- Draw a whisker from 16 to the maximum, 21.
- Place the data values at equal numerical distances on the axis.
The box represents the middle half of the data. Its width is the interquartile range:
\[ \text{IQR}=Q3-Q1=16-6=10 \]
The left whisker covers the distance from 3 to 6. The right whisker covers the distance from 16 to 21.
Whiskers and Outliers
A basic boxplot may use the minimum and maximum as the whisker endpoints. When a problem uses the 1.5 times IQR rule, the whiskers usually stop at the most extreme data values that are not outliers.
For the example:
\[ Q_1-1.5(\text{IQR})=6-15=-9 \]
\[ Q_3+1.5(\text{IQR})=16+15=31 \]
Every value from \(-9\) through 31 is within the fences, so 3 and 21 are not outliers. They become the whisker endpoints.
Use Code to Check the Calculations
This code follows the median-of-halves method. It prints the five-number summary and the IQR.
def median(values):
n = len(values)
middle = n // 2
if n % 2 == 1:
return values[middle]
return (values[middle - 1] + values[middle]) / 2
def five_number_summary(data):
values = sorted(data)
middle = len(values) // 2
lower = values[:middle]
upper = values[middle + len(values) % 2:]
return values[0], median(lower), median(values), median(upper), values[-1]
data = [3, 5, 7, 8, 12, 13, 14, 18, 21]
minimum, q1, med, q3, maximum = five_number_summary(data)
print("Five-number summary:", minimum, q1, med, q3, maximum)
print("IQR:", q3 - q1)The output is the summary \(3,6,12,16,21\), followed by an IQR of 10.
GRE Strategy
When a question gives a boxplot, identify the five positions before calculating anything. The left and right edges of the box are \(Q1\) and \(Q3\). The line inside the box is the median. The whisker endpoints are usually the minimum and maximum unless outliers are shown separately.
Exercise
A data set has five-number summary 4, 9, 15, 22, 30. What are the box endpoints, median line, whisker endpoints, and IQR in its basic boxplot?
Show answer
The box extends from 9 to 22, the median line is at 15, the whiskers extend to 4 and 30, and the IQR is 22 - 9 = 13.