Boxplots

Boxplot basics

We are going to learn how to do all sorts of things with boxplots. But first, we have to learn what they are and what all the pieces tell us.

Let's start with outliers and how to find them. You've seen this word a few times in the course already, but we need a formal mathematical definition so that we can work with boxplots.

So, get out that notebook and let’s take some notes. This might look like a lot, but it's important to understand before we move on.

Take some notes!

Outlier – a piece of data that lies outside the overall pattern of data. For example, if the data is: [13, 13, 13, 14, 14, 14, 15, 89] then 89 is probably an outlier since it is so far outside the overall pattern.

How to find outliers
If data is above the Upper Fence or below the Lower Fence, it is an outlier.

How to calculate the upper and lower fences:
Upper Fence (UF) = Q3 + 1.5 x IQR
Lower Fence (LF) = Q1 – 1.5 x IQR

(We learned about the quartiles and interquartile range earlier this week.)

5 number summary
If a question asks for the '5 number summary', you need to give: the min (lowest value), the Q1, med (median), Q3, and the max (highest value). If there is an outlier, it is not counted in your 5 number summary. These are the same numbers we represent with a boxplot.

Boxplot – a way of displaying numerical data, both discrete and continuous. It consists of a 'box' that shows five elements: the Q1, median, Q3 and (usually) a pair of 'whiskers', that stretch to the minimum (min) and maximum (max) value of the data. Sometimes, these are also called box-and-whisker plots.

Example: Boxplot without outliers

Note: Your boxplots don’t have to look exactly like this example. The labels here are just for your notes – the boxplots we work with won’t have them.

© State of Victoria (DE) Virtual School Victoria 2022.

Example: Boxplot with outliers

Note: Again, your boxplot drawings don’t have to look exactly like this example. The labels are just for your notes – the boxplots we work with won’t have them.

© State of Victoria (DE) Virtual School Victoria 2022.

Interpreting the shape of a boxplot

Boxplots can be symmetrical, positively skewed or negatively skewed just like other data displays (see Week 1).

Symmetrical boxplot
Positively skewed boxplot
Negatively skewed boxplot

Adapted from zizou7 / Shutterstock.com

How to make a boxplot

  1. Find the min, Q1, median, Q3 and max, either by hand or with technology, and write them down in a list that looks like this:
    min - ___, Q1 - ___, med - ___, Q3 - ___, max - ___, outlier(s) - ________
  2. Calculate the UF and the LF.
  3. If a piece of data is above the UF or below the LF, it is an outlier. If the minimum or maximum in your Step 1 list is an outlier, replace it with the smallest non-outlier (for the min) or the largest non-outlier (for the max).
  4. Create a number line that has a low value below the min and an upper value above the max, making sure you have space above the number line to make the boxplot.
  5. Make three vertical lines a bit above the number line (look at the lines labelled Q1, med, and Q3 in the example) at the values for the Q1, med, and Q3.
  6. Connect those three lines to make a box..
  7. Put dots above the min and max, making sure you have changed the min and max to reflect any outliers. Make sure the dots are centred on the box you just made.
  8. Connect the dots to the outside of the box that you made in Step 4. (Don’t draw through the box!)
  9. Put dots above any outliers.

After you have written this down, watch the video below on 'the Five Number Summary, Box Plots and Outliers' which explains it in further detail.

Video summary

This video explains how to use the five-number summary to create and interpret boxplots, identify outliers and compare data sets.

  • Five-number summary: The minimum, first quartile (Q1), median, third quartile (Q3) and maximum describe how data is distributed.
  • Boxplots: The box represents the middle 50% of the data, from Q1 to Q3, with a line marking the median. The whiskers extend towards the smallest and largest values.
  • Identifying outliers: Calculate the interquartile range (IQR = Q3 − Q1), then use the lower fence (Q1 − 1.5 × IQR) and upper fence (Q3 + 1.5 × IQR).
  • Worked example: Using Q1 = 25 and Q3 = 36, the IQR is 11. The lower fence is 8.5 and the upper fence is 52.5, making the value 59 an outlier.
  • Modified boxplots: Outliers are shown as separate dots, while the whiskers extend only to the smallest and largest non-outlier values. In the example, the upper whisker ends at 50 instead of 59.
  • Side-by-side boxplots: Placing boxplots next to each other makes it easier to compare the distributions of different data sets.
Interactive

Use the interactive below to check how a box plot changes when the 5 number summary changes.