Box plot fences are calculated using the first quartile (Q1), third quartile (Q3), and the interquartile range (IQR). The standard formula multiplies the IQR by 1.5, then subtracts that value from Q1 for the lower fence and adds it to Q3 for the upper fence. Fences are invisible boundaries that determine where the whiskers end and where outliers begin.
The Fence Formulas
A box plot actually has two sets of fences: inner fences and outer fences. Most statistics courses focus on the inner fences, which are the ones used to identify typical outliers. Here are all four:
- Lower inner fence: Q1 − 1.5 × IQR
- Upper inner fence: Q3 + 1.5 × IQR
- Lower outer fence: Q1 − 3 × IQR
- Upper outer fence: Q3 + 3 × IQR
The IQR is simply Q3 minus Q1, which captures the spread of the middle 50% of your data. The 1.5 multiplier is a convention introduced by John Tukey, the statistician who created the box plot. It strikes a practical balance for flagging values that sit unusually far from the central bulk of your data.
Step-by-Step Calculation
To find the fences from raw data, work through these steps in order:
1. Order your data from smallest to largest. For example: 58, 65, 70, 73, 78, 82, 85, 88, 92, 110.
2. Find Q1 and Q3. Q1 is the median of the lower half of your data, and Q3 is the median of the upper half. In the example above, Q1 = 70 and Q3 = 88.
3. Calculate the IQR. Subtract Q1 from Q3. Here, 88 − 70 = 18.
4. Multiply the IQR by 1.5. That gives 18 × 1.5 = 27.
5. Subtract from Q1 and add to Q3. The lower inner fence is 70 − 27 = 43. The upper inner fence is 88 + 27 = 115.
If you also need the outer fences, multiply the IQR by 3 instead. In this example: lower outer fence = 70 − 54 = 16, and upper outer fence = 88 + 54 = 142.
Fences vs. Whiskers
This is the distinction that trips most people up. Fences are invisible boundaries. They never appear on the actual plot unless they happen to coincide exactly with a data point. Whiskers, on the other hand, are the lines you see extending from either end of the box.
The whiskers reach to the most extreme data points that fall within (or right at) the fences. Specifically, the lower whisker extends from Q1 down to the smallest value in your dataset that is greater than or equal to the lower fence. The upper whisker extends from Q3 up to the largest value that is less than or equal to the upper fence. Any data point beyond a fence gets plotted individually as a dot or circle, marking it as an outlier.
So fences set the rules, and whiskers follow them. The whiskers will almost never land exactly on the fence values because they snap to the nearest actual data point inside the boundary.
How Fences Classify Outliers
The two sets of fences create two categories of unusual values. According to the National Institute of Standards and Technology, a data point that falls beyond an inner fence (but not past the outer fence) is a mild outlier. A point beyond an outer fence is an extreme outlier.
In practice, mild outliers are common enough that they may not signal a problem. They could reflect natural variation. Extreme outliers, on the other hand, often warrant investigation. They could indicate a data entry error, a measurement problem, or a genuinely unusual observation worth understanding on its own terms. Using the example above, a value of 120 would be a mild outlier (past the upper inner fence of 115, but below the upper outer fence of 142), while a value of 150 would be extreme.
How Software Handles Fences
If you’re building box plots in code rather than by hand, most libraries default to the same 1.5 × IQR rule. In Python’s Matplotlib, the boxplot function uses a whis parameter that defaults to 1.5. The lower whisker is drawn at the lowest data point above Q1 − 1.5 × IQR, and the upper whisker at the highest data point below Q3 + 1.5 × IQR. R’s boxplot function follows the same convention.
You can change the multiplier by adjusting that parameter. Setting whis=2.0 in Matplotlib, for instance, would widen the fences and result in fewer points being flagged as outliers. Setting it lower would tighten the fences and flag more.
When the Standard Fences Mislead
The 1.5 × IQR rule assumes your data is roughly symmetric. If your data is heavily skewed (income data, for example, where a long tail stretches to the right), the standard fences will flag too many points on the long-tail side as outliers even when those values are perfectly normal for that distribution.
One alternative uses the semi-interquartile ranges, which split the IQR into two halves (Q2 − Q1 for the lower side, Q3 − Q2 for the upper side) and apply different fence distances on each side. A more robust approach, known as the adjusted boxplot, incorporates a measure of skewness called the medcouple to shift the fences asymmetrically. This method works for any distribution shape, even those without well-defined averages. For most introductory statistics work, the standard 1.5 rule is sufficient, but if you’re working with real-world data that has an obvious skew, these adjusted methods produce more meaningful outlier detection.

