Tutorials › Introduction to Statistics › Side-By-Side Boxplots on a Common Scale

Comparing Groups and Handling Outliers · Tutorial 176 of 996

Side-By-Side Boxplots on a Common Scale

Construct and interpret side-by-side boxplots on one common scale so their boxes, whiskers, and flagged observations can be compared fairly.

Beginner 9 min read

What You'll Learn

  • Calculate medians and quartiles using the stated median-of-halves convention.
  • Translate five-number summaries into boxes, median lines, and whiskers.
  • Recognize how a modified boxplot displays flagged observations.
  • Choose shared limits and units for aligned group plots.
  • Explain how separate axis scales can distort visual comparisons.

Why Put Boxplots Side by Side?

When several groups are measured in the same units, aligned boxplots provide a compact view of each group’s distribution. Each plot uses the same visual parts: a box for the middle half of the observations, a line for the median, whiskers for the ordinary range, and, in a modified boxplot, separate marks for flagged observations. The comparison is fair only when the plots share a numerical scale.

Imagine that two clinics record patient waiting times in minutes. If one boxplot uses an axis from 0 to 40 and another uses an axis from 30 to 70, equal-sized boxes on the screen do not necessarily represent equal differences in minutes. A common axis makes a given distance on the page correspond to the same numerical distance in every group.

Definition: Side-by-side boxplots on a common scale are boxplots for two or more groups, aligned in separate rows (or columns), with a shared numerical axis that uses the same units, tick marks, and scale for every group.

The observations should be quantitative and measured in comparable units. If one group is recorded in minutes and another in seconds, convert them to one unit before plotting. Every plot should use the same scale direction and the same quartile and whisker conventions. A common scale does not require every group to have the same sample size.

What Each Boxplot Shows

A boxplot is built from the five-number summary: the minimum, first quartile \(Q_1\), median, third quartile \(Q_3\), and maximum. The box extends from \(Q_1\) to \(Q_3\), with a line at the median. The numerical width of the box is the interquartile range, \(IQR=Q_3-Q_1\). In a modified boxplot, whiskers extend to the most extreme observations that have not been flagged; flagged observations are shown separately.

Quartile values can differ slightly across software because different conventions are used. To make the calculations in this tutorial unambiguous, use the median-of-halves convention: sort the observations; find the overall median; if the sample size is odd, leave that median out and divide the remaining observations into lower and upper halves; if the sample size is even, divide the observations into equal halves. \(Q_1\) is the median of the lower half, and \(Q_3\) is the median of the upper half. When a half has an even number of observations, its median is the mean of its two middle values.

For the modified boxplots here, a value is flagged if it is below \(Q_1-1.5(IQR)\) or above \(Q_3+1.5(IQR)\). These limits are called the lower and upper fences. A whisker ends at the most extreme observed value that is still within the fences; it does not have to reach the fence itself. A flagged value is plotted individually beyond the whisker. The rule identifies unusual values for display; a flag alone does not establish that an observation is an error.

Constructing Aligned Plots

A reliable construction begins with summaries, not with sketching. Calculate each group’s quartiles using the same convention, determine any flagged observations, and then choose one horizontal or vertical axis that accommodates all the values to be shown. Mark the same tick values at the same physical positions for every group. Draw the boxes and median lines at the appropriate locations; then add whiskers and any individual flagged points. Each row should be labelled with its group name and sample size when that information is available.

1
Check the measurements.
Confirm that the variable is quantitative and that every group is expressed in the same units.
2
Calculate summaries consistently.
Sort each group’s data and find its median, \(Q_1\), and \(Q_3\) using one stated convention.
3
Set the shared axis.
Choose common limits and tick marks that include all plotted observations, including flagged points.
4
Draw and label each group.
Place the box, median, whiskers, and any flagged observations at their numerical positions on the same axis.

Worked Example: Building Two Boxplots from the Data

Suppose two hypothetical groups have waiting times, in minutes, as follows:

Group A: 40, 45, 50, 55, 60.
Group B: 50, 55, 60, 65, 70.

Both samples contain five observations. For Group A, the median is 50. Excluding that median leaves lower half \(40,45\) and upper half \(55,60\), so

$$ Q_1=\frac{40+45}{2}=42.5,\qquad Q_3=\frac{55+60}{2}=57.5,\qquad IQR=57.5-42.5=15. $$

For Group B, the median is 60. The lower half is \(50,55\), and the upper half is \(65,70\). Therefore,

$$ Q_1=\frac{50+55}{2}=52.5,\qquad Q_3=\frac{65+70}{2}=67.5,\qquad IQR=67.5-52.5=15. $$

For Group A the fences are \(42.5-1.5(15)=20\) and \(57.5+1.5(15)=80\); all observations lie between them. For Group B the fences are \(52.5-1.5(15)=30\) and \(67.5+1.5(15)=90\); again, all observations lie between them. Thus each group’s whiskers reach its minimum and maximum. On a shared axis from 35 to 75 minutes, draw A’s box from 42.5 to 57.5 with its median at 50, and B’s box from 52.5 to 67.5 with its median at 60. Both boxes are 15 minutes long.

Why the Shared Scale Matters

A common axis makes physical distances on the plot comparable. This follows directly from how a linear scale maps values to positions. Let an axis run from \(L\) to \(U\) across a physical length \(W\), beginning at position \(x_0\). A value \(v\) is placed at position

$$ x(v)=x_0+W\frac{v-L}{U-L}. $$

For two values \(v_1\) and \(v_2\), subtract their positions:

$$ x(v_2)-x(v_1) = \left(x_0+W\frac{v_2-L}{U-L}\right) - \left(x_0+W\frac{v_1-L}{U-L}\right) = W\frac{v_2-v_1}{U-L}. $$

If the groups share \(L\), \(U\), and \(W\), then the same numerical difference \(v_2-v_1\) always occupies the same physical distance. With separate axes, the denominator \(U-L\) can differ, so identical differences can look unequal—or unequal differences can look similar.

Worked Example: Seeing the Effect of Different Axis Ranges

The two groups in the previous example have equal IQRs of 15 minutes. Suppose each plot is drawn 6 cm wide. On a common axis from 35 to 75, the axis span is \(75-35=40\) minutes. Each box therefore has physical width

$$ 6\text{ cm}\times\frac{15\text{ min}}{40\text{ min}} =2.25\text{ cm}. $$

Now imagine using a separate axis from 35 to 75 for Group A, but an axis from 48 to 72 for Group B. Group B’s 15-minute box would occupy

$$ 6\text{ cm}\times\frac{15\text{ min}}{72-48\text{ min}} =3.75\text{ cm}. $$

The data give the two groups exactly equal IQRs, but the separate scales make B’s box look longer. A reader might mistake the plotting choice for a difference in spread. Keeping the scale common gives both boxes the same 2.25 cm width and places their values at positions that can be read directly against the shared minute axis.

Whiskers and Flagged Observations on a Shared Axis

In a modified boxplot, the whiskers and flagged points are part of the display, not decorations. The whiskers show the reach of the observations that remain within the fences; a separate point shows the location of a flagged observation. A common axis is especially useful here because it shows how far that point lies from the box and whisker, and allows its position to be compared with points in other groups.

Worked Example: Plotting a Flagged Observation

Consider the hypothetical waiting times \(10,12,13,14,15,16,18,45\), in minutes. There are eight observations, so split the sorted list into equal halves. The overall median is \((14+15)/2=14.5\). The lower half is \(10,12,13,14\), giving \(Q_1=(12+13)/2=12.5\). The upper half is \(15,16,18,45\), giving \(Q_3=(16+18)/2=17\). Thus

$$ IQR=17-12.5=4.5. $$

The lower fence is \(12.5-1.5(4.5)=5.75\), and the upper fence is \(17+1.5(4.5)=23.75\). The values 10, 12, 13, 14, 15, 16, and 18 are within the fences; 45 is above the upper fence. Draw the box from 12.5 to 17, with its median at 14.5. The lower whisker reaches 10, and the upper whisker reaches 18. Plot 45 separately rather than extending the whisker to it. On an axis shared with other groups, make sure the scale includes 45 so the flagged point is not hidden or cut off.

Different software may use different quartile conventions, so a plotted box can differ slightly between sources even when the data are identical. If reproducing or checking a plot, identify the convention where possible. Within a single side-by-side display, consistency is essential: using one quartile convention for one group and another for a second group can create differences that come from calculation rather than data.

Common Mistakes and a Practical Check

  • Using separate scales for each group. The mistaken reasoning is that each group needs an axis fitted to its own range to make its box easier to see. The correction is to use one shared scale for a direct visual comparison; if a group’s box is too small to inspect, use a clearly explained enlargement in addition to, not instead of, the common-scale display.
  • Confusing the box length with the full range. The box runs from \(Q_1\) to \(Q_3\), so its length represents the IQR, not the distance from the minimum to the maximum.
  • Extending a modified-boxplot whisker to a flagged point. In this convention the point is marked separately, and the whisker ends at the most extreme non-flagged observation.
  • Comparing plots with inconsistent calculations. Quartiles depend on the selected convention. Use the same one for every group and state it when the calculation matters.
  • Reading visual overlap as a complete account of the data. Boxplots summarize distributions; they do not show every observation or every detail of distribution shape.

Before interpreting an aligned display, check that the axis labels name the variable and units, every group has the same tick spacing and limits, and boxes, whiskers, and individual points have been placed according to the same rules. Then read positions from the common axis rather than judging them only by eye.

Key takeaway: Side-by-side boxplots are comparable when every group is plotted on the same numerical scale and summarized using consistent conventions. The shared scale preserves the visual meaning of distances; each box, median line, whisker, and flagged point can then be read in the measurement’s original units.

Check Your Understanding

Answer each question using the conventions described above.

  1. For the sorted values \(2,4,6,8,10\), find the median, \(Q_1\), and \(Q_3\) using the median-of-halves convention.
  2. A group has \(Q_1=12\) and \(Q_3=20\). What is its IQR, and where are the lower and upper fences for the modified-boxplot rule?
  3. Why can equal IQRs appear to have different box lengths when groups use separate axis ranges?
  4. A group’s upper whisker ends at 31, and a separate point appears at 44. What does that display indicate about the plotted observations under the modified-boxplot convention?
  5. Two groups were measured in seconds and minutes. What must be done before their boxplots are placed on a common scale?