= Box plot
{wiki}
A <box plot> compresses a <statistical sample> into a box spanning its lower and upper <quartiles> $Q_1,Q_3$, a line at its <median> $Q_2$, and two whiskers. It makes location and central spread easy to compare across groups on a common value axis. The box represents the central half in terms of <quantile> levels; with ties or interpolated <quartiles>, it need not contain exactly half the observations. Whisker endpoints require a stated convention: they can be the observed extremes, or they can stop short of separately marked observations. https://www.itl.nist.gov/div898/handbook/eda/section3/boxplot.htm[NIST/SEMATECH, Box Plot, definition and variants]{ref}
Here is one explicitly toy dataset, reused under <histogram>: twelve invented, unitless values, with repeated values counted separately, already arranged as <order statistics>:
$$
(x_{(1)},\ldots,x_{(12)})=(1,2,2,3,4,4,5,6,6,7,8,20).
$$
For this <box plot> we choose the interpolated <quartiles> defined under <quartile>, using R's type-7 rule. This gives
$$
Q_1=2+\tfrac34(3-2)=2.75,\qquad Q_2=4+\tfrac12(5-4)=4.5,\qquad Q_3=6+\tfrac14(7-6)=6.25.
$$
The <interquartile range> is $I=Q_3-Q_1=3.5$. Our whisker convention uses the fences
$$
L=Q_1-1.5I=-2.5,\qquad U=Q_3+1.5I=11.5.
$$
The whiskers end at the smallest and largest observations in the closed <interval> $[L,U]$: here $1$ and $8$. Values strictly outside the fences receive separate <outlier> markers: here only $20$. An observation exactly on a fence is retained within the whisker under this convention. The fences are thresholds, not observed whisker endpoints; the upper whisker is at $8$, not $11.5$. R's documented whisker rule likewise includes observations no more than $1.5$ box lengths away, although its box uses hinges, which can differ from our type-7 <quartiles>. https://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/boxplot.stats.html[R grDevices documentation, boxplot.stats, coef and hinges]{ref}
\Image[/boxplot-quartile-fences-toy.png]
{title=Toy box plot: quartiles define the box, observations define the whiskers}
{description=The twelve invented values are shown individually below the <box plot>, with repeated values stacked. Type-7 <quartiles> are $2.75,4.5,6.25$; the <interquartile range> is $3.5$. Dashed fences at $-2.5$ and $11.5$ determine whiskers at $1$ and $8$ and a separate marker at $20$. The fence lines and raw-value strip are explanatory additions, not required parts of every <box plot>.}
A separate <outlier> marker is a prompt to investigate, not a finding that the value is bad data and not an instruction to delete it. A distant observation can be a recording error, a legitimate unusual outcome, or evidence that the assumed <statistical model> misses some behavior. Check its provenance and context before deciding how to analyze it. No measurement-error claim is possible for our invented $20$: we deliberately put it there to demonstrate the rule. https://www.itl.nist.gov/div898/handbook/eda/section3/eda35h.htm[NIST/SEMATECH, Detection of Outliers, labeling and investigation]{ref}
The beauty of a <box plot> is its compact comparison of ordered positions rather than every observation. That compression also loses information: many different <statistical samples> have the same <quartiles> and whiskers, so the box alone cannot reveal every cluster or gap that a <histogram> might show. For example, replacing the two invented $6$ values by $5.5$ and $6$ leaves the type-7 <quartiles>, whiskers and separate marker unchanged. Displaying the individual values alongside the <box plot> is especially helpful for such a small <statistical sample>. Always state both the <quartile> rule and the whisker rule; changing either can change which values are marked.
Back to article page