Skip to content
ComputerCS
Start learning

Data Analytics · Lesson 5.4.1.5

Boxplots and Distribution Summaries

Read a boxplot using the median, quartiles, interquartile range, whiskers and possible outliers.

01

Learning objectives

  • Define the median, lower quartile and upper quartile.
  • Calculate and interpret the interquartile range.
  • Read the centre and spread from a boxplot.
  • Explain why potential outliers require investigation.
02

Lesson notes

A boxplot summarises a numeric distribution using the five-number summary: minimum, first quartile (Q1), median, third quartile (Q3) and maximum, although whisker conventions may exclude outliers. The box extends from Q1 to Q3, with a line at the median. The box therefore contains the middle half of the observations.

The interquartile range is IQR = Q3 − Q1. It measures the spread of the middle 50% of the data and is less affected by extreme values than the full range. A larger IQR indicates more spread among the central observations. Quartile calculation conventions can differ for small datasets, so follow the convention specified by the textbook or teacher.

Whiskers commonly extend to the most extreme observations within 1.5 × IQR from the quartiles. Values beyond that threshold are plotted separately as potential outliers. They are not automatically mistakes: an outlier may represent a rare but valid observation, a measurement error or a different subpopulation.

Boxplots help compare distributions across groups by showing median and spread on a common scale. They do not reveal every individual data value or the shape of multiple peaks. Pair them with sample size, context and other visualisations before making a conclusion.

03

Worked code examples

Worked example

The sample uses stated quartiles to calculate IQR and the common upper outlier fence. Quartiles should be calculated using the prescribed convention for the dataset.

values = [4, 5, 6, 7, 8, 9, 10, 11, 30]
q1, median, q3 = 5, 8, 11
iqr = q3 - q1
upper_fence = q3 + 1.5 * iqr
print("IQR:", iqr)
print("Upper fence:", upper_fence)
print("Potential high outliers:", [x for x in values if x > upper_fence])
Output
IQR: 6
Upper fence: 20.0
Potential high outliers: [30]
04

Key terminology

Quartile

A cut point dividing ordered data into four parts.

IQR

The interquartile range, Q3 minus Q1.

Median

The middle observation or the mean of the two middle observations.

Outlier fence

A threshold often set at 1.5 × IQR beyond a quartile.

05

Common misconceptions

Common mistake

Every point beyond a whisker is definitely an error.

Correct understanding

A potential outlier needs contextual investigation; it may be a valid rare observation.

Common mistake

The box contains all observations.

Correct understanding

The box represents the middle 50%; whiskers and separate markers show the rest.

06

Check your understanding

1. What does the box in a standard boxplot represent?

2. How is IQR calculated?

3. A point beyond a 1.5 × IQR whisker is best described as:

NERDLYY · FEEDBACK

Help shape Nerdlyy

Your feedback goes directly to the team. We read every submission.

No reply needed — you can send feedback without sharing contact details.