Box Plots

Category: Statistics   Level: 301

IQR = Q3 - Q1; outlier if beyond Q3 + 1.5 IQR or Q1 - 1.5 IQR

Sort the data, split it at the median, and split each half again to get the quartiles. The box spans the middle half, whiskers reach the furthest ordinary values, and anything past 1.5 IQR from the box is flagged.

Step through it

Watch it

Animated walkthrough

Step by step

Step 1: Sort the data

Write the 15 values from smallest to largest. Number the positions so the middle is easy to find.

n = 15

Step 1: Sort the data

Step 2: Find the median

Position 8 sits in the middle, with 7 values on each side. Its value is the median, Q2.

Q2 = 11

Step 2: Find the median

Step 3: Find the quartiles

Take the median of each half, leaving Q2 out. These are Q1 and Q3: a quarter of the data sits below Q1 and a quarter above Q3.

Q1 = 8, Q3 = 15

Step 3: Find the quartiles

Step 4: Draw the box

On a number line, draw a box from Q1 to Q3 with a line at the median. The box holds the middle half of the data; its width is the IQR.

IQR = 15 - 8 = 7

Step 4: Draw the box

Step 5: Set the outlier fences

Step 1.5 IQR out from each end of the box. Values past these fences count as outliers.

8 - 1.5 × 7 = −2.5; 15 + 1.5 × 7 = 25.5

Step 5: Set the outlier fences

Step 6: Draw whiskers and flag the outlier

Whiskers run to the smallest and largest values inside the fences, 3 and 18. The 31 sits past the fence, so it gets its own dot. Somebody either aced it or typed it wrong.

whiskers 3 to 18; outlier 31

Step 6: Draw whiskers and flag the outlier

All steps at once

Storyboard

Generate it yourself

cd svg-generator
python3 -m svgmath render box-plot --out /tmp/box-plot

Source: svgmath/diagrams/statistics.py