Boxplot (box and whisker plot): how to make and read one

Updated

A boxplot, or box and whisker plot, summarizes a set of values with five numbers and flags unusual points. The box runs from the first quartile to the third, so it holds the middle half of the data; a line inside marks the median; whiskers reach out to the most extreme values that are not outliers; and outliers appear as separate symbols. Because each box is compact, boxplots are the standard way to compare the center and spread of several groups side by side.

When to use it

  • You want to compare a measurement across groups: machines, shifts, suppliers, cavities, operators.
  • You need a quick screen for outliers before running a test or a capability analysis.
  • You want a summary that resists extreme values: the median and quartiles barely move when one value is wild.
  • Each group has at least 10 or so values. With fewer, show the points themselves in an individual value plot.

How it works

Sort the values of each group and compute:

  1. Quartiles. Q1, the median and Q3 sit at rank (n + 1)p of the sorted data, with p = 0.25, 0.5 and 0.75, interpolating between neighbors when the rank is not a whole number. This is the rule used in descriptive statistics; other programs use slightly different rules, so small samples can give slightly different boxes.
  2. Interquartile range. IQR = Q3 − Q1, the height of the box.
  3. Fences. Values beyond these limits are outliers:
Lower fence = Q1 − 1.5 × IQR Upper fence = Q3 + 1.5 × IQR
  1. Whiskers. Each whisker runs from the box to the most extreme data value that is still inside its fence. The whisker ends at a real data point, not at the fence itself.
  2. Outliers. Every value beyond a fence is drawn as its own symbol.

For data from a normal distribution, the fences sit about 2.7 standard deviations from the mean, so only about 0.7% of values fall outside them. An outlier on a boxplot is therefore a value worth checking, not proof of an error. Some boxplots also mark the mean with a symbol, or add notches that show a confidence interval for the median.

Example

A packaging line seals pouches with a heated jaw. The quality lab pulls 15 pouches per shift and measures seal strength in N/15 mm; the lower specification limit is 35 N/15 mm. Here are the 15 values from Shift 2, sorted:

34.6, 39.7, 40.0, 40.0, 41.2, 41.4, 41.5, 41.9, 42.1, 42.5, 42.7, 43.0, 43.1, 43.6, 44.5

With n = 15, Q1 is at rank 16 × 0.25 = 4, the median at rank 8 and Q3 at rank 12, so Q1 = 40.0, median = 41.9 and Q3 = 43.0. IQR = 3.0, the lower fence is 40.0 − 4.5 = 35.5 and the upper fence 43.0 + 4.5 = 47.5. The value 34.6 is below the lower fence, so it is an outlier; the lower whisker stops at 39.7, the smallest value inside the fence.

All three shifts:

ShiftMinQ1MedianQ3MaxIQRWhiskersOutliers
139.140.341.943.344.73.039.1 to 44.7none
234.640.041.943.044.53.039.7 to 44.534.6
335.937.239.540.341.63.135.9 to 41.6none
Boxplot of seal strength by shift35.037.540.042.545.0Seal strength (N/15 mm)Shift 1Shift 2Shift 3
Boxplot of seal strength by shift

The plot tells two separate stories. Shift 3's whole box sits lower: its median of 39.5 is 2.4 N/15 mm below the other shifts, while its IQR is about the same. That is a shift in level, which points to a setting (jaw temperature, dwell time or pressure) that differs on that shift. Shift 2 looks like Shift 1 except for one pouch at 34.6, below the specification limit. That is an isolated event; the lab should find that pouch's record before deciding anything.

How to read the results

  • Medians. Compare the lines inside the boxes. A difference that is large compared with the box heights is likely real; confirm it with a test such as one-way ANOVA or Kruskal-Wallis.
  • Box heights. A taller box means more spread in the middle half of the data.
  • Symmetry. A median close to one end of the box, or one whisker much longer than the other, means a skewed distribution.
  • Outliers. Check each one against its record: a typing error, a measurement problem, or a real special cause.
  • Box positions versus specifications. Draw the limits on the plot when you have them. A whisker near a limit is a warning even if no value is out yet.

Common mistakes

  • Boxplots of tiny groups. With 5 values, a box is almost all interpolation. Show the points instead.
  • Hiding a second peak. A boxplot cannot show two clusters; a group with two modes can look like an ordinary wide box. Look at a histogram or dotplot as well.
  • Deleting every outlier. The 1.5 × IQR rule flags values to investigate, not values to remove. For a formal decision, use an outlier test.
  • Reading the whiskers as the range or as ±3σ. They stop at the last value inside the fences, which may be well inside the full range.
  • Comparing boxes from different quartile rules. Programs differ slightly; use one tool for one comparison.

Frequently asked questions

What does the box in a boxplot represent?

The box runs from the first quartile (Q1) to the third quartile (Q3), so it contains the middle 50% of the values. The line inside the box is the median.

How are outliers defined on a boxplot?

A value is plotted as an outlier when it lies more than 1.5 × IQR below Q1 or above Q3, where IQR = Q3 − Q1.

How long are the whiskers?

Each whisker extends to the most extreme data value that is still within 1.5 × IQR of the box. If there are no outliers, the whiskers reach the minimum and the maximum.

When should I use a boxplot instead of a histogram?

Use boxplots to compare several groups side by side. Use a histogram to study the detailed shape of one group, especially when you suspect two peaks.

Try it with your own data

StatLab SPC is free, open-source statistics for engineers. It runs in your browser, works offline, and never uploads your data.

Open StatLab