Skip to content
Tutorials Center
My learning

Topics

Lesson 14 of 37 ยท Averages and Spread

Box Plots and Outliers

Draw and interpret box-and-whisker plots from the five-number summary, apply the 1.5 times IQR rule to find outliers, and compare groups side by side.

A box plot (also called a box-and-whisker diagram) shows the shape and spread of a data set in a compact picture. It is built from just five numbers, so you can fit several next to each other and compare groups at a glance.

The five-number summary

  1. Minimum
  2. Q1 (lower quartile)
  3. Median
  4. Q3 (upper quartile)
  5. Maximum

For the data 5, 7, 8, 9, 10, 11, 12, 14, 15, 18 (n = 10): minimum 5; the lower half is 5, 7, 8, 9, 10 so Q1 = 8; median = (10 + 11) / 2 = 10.5; the upper half is 11, 12, 14, 15, 18 so Q3 = 14; maximum 18. The IQR is 14 โˆ’ 8 = 6.

Drawing a box plot

  1. Draw a number line (or a vertical axis) covering the data range.
  2. Draw a box from Q1 to Q3.
  3. Draw a line in the box at the median.
  4. Draw whiskers from the box to the minimum and maximum (or to the most extreme non-outlier values).

The whole box contains the middle 50% of the data, and each whisker covers about a quarter.

flowchart LR
  A["Min"] --- B["Q1"] --- C["Median"] --- D["Q3"] --- E["Max"]
  style B fill:#cfe8ff,stroke:#333
  style C fill:#cfe8ff,stroke:#333
  style D fill:#cfe8ff,stroke:#333

The box runs from Q1 to Q3; whiskers reach out to the minimum and maximum.

Python A box plot of the example data

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Matplotlib uses interpolated quartiles, so its box edges may differ slightly from the median-of-halves values you computed by hand.

Reading box plots

  • A long box means a large IQR (more spread in the middle).
  • A median off-center in the box, or unequal whiskers, suggests skew. If the longer whisker is on the right, the data are right-skewed.
  • The box plot does not show individual values or how many peaks there are.

Outliers: the 1.5 ร— IQR rule

A common rule says a value is a suspected outlier if it lies below the lower fence or above the upper fence:

lower fence = Q1 โˆ’ 1.5 ร— IQR

upper fence = Q3 + 1.5 ร— IQR

Now add a value 30 to the data (n = 11). The median is 11, the lower half 5, 7, 8, 9, 10 gives Q1 = 8, and the upper half 12, 14, 15, 18, 30 gives Q3 = 15. So the IQR is 7 and the upper fence is 15 + 1.5 ร— 7 = 25.5. The value 30 lies above it, so it is plotted as a separate dot, an outlier. The whisker then stops at the largest value inside the fence (18).

The 1.5 ร— IQR rule is a convention, not a law. A flagged value deserves investigation: it may be a typing error, a faulty measurement or a genuine unusual case. Do not delete data just because it is an outlier.

Python Find outliers with the 1.5 x IQR rule

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Comparing groups with box plots

Placing box plots on the same scale makes comparison easy. Compare medians (typical level), IQRs (spread) and any skew or outliers.

Python Compare two classes

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Class B has a wider box and longer whiskers, so its scores are more spread out, even if the two medians look close. A written comparison should mention both: "Class B's median is slightly higher, but its results are much more variable."

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which values make up the five-number summary?

    The box plot is drawn from the minimum, lower quartile, median, upper quartile and maximum.
  2. 2. Q1 = 12 and Q3 = 20. What is the upper fence for outliers?

    IQR = 20 โˆ’ 12 = 8, and 1.5 ร— 8 = 12, so the upper fence is 20 + 12 = 32.
  3. 3. A box plot's box represents about

    The box runs from Q1 to Q3, which contains about half the observations.
  4. 4. A box plot has a short left whisker and a long right whisker. The data are most likely

    A long upper tail indicates right skew.

Summary

  • The five-number summary (min, Q1, median, Q3, max) defines a box plot.
  • The box holds the middle 50%; the line is the median; whiskers extend to the extremes.
  • Outliers are flagged beyond Q1 โˆ’ 1.5 ร— IQR and Q3 + 1.5 ร— IQR.
  • Compare groups by median, IQR and skew, on a common scale.

Next: The Probability Scale