# How to read a boxplot in R? [duplicate]

When using the default settings (boxplot(x.ts)), what do the whiskers, boxes, midlines and outliers represent? Does it show quartiles or standard deviations?

Where is this documented?

The documentation seems fairly clear to me, although it certainly helps to be familiar with how to read R documentation and with boxplots more generally. Towards the bottom of the page it says:

boxplot.stats which does the computation...

So we can navigate there. It reads:

Details

The two ‘hinges’ are versions of the first and third quartile, i.e., close to quantile(x, c(1,3)/4). The hinges equal the quartiles for odd n (where n <- length(x)) and differ for even n. Whereas the quartiles only equal observations for n %% 4 == 1 (n = 1 mod 4), the hinges do so additionally for n %% 4 == 2 (n = 2 mod 4), and are in the middle of two observations otherwise.

And the Values section includes:

stats a vector of length 5, containing the extreme of the lower whisker, the lower ‘hinge’, the median, the upper ‘hinge’ and the extreme of the upper whisker.

Moreover, above that we see that the argument coef is set to 1.5 by default (so that is what you would get unless you had changed the default for range in the original boxplot call). The coef argument is documented:

coef this determines how far the plot ‘whiskers’ extend out from the box. If coef is positive, the whiskers extend to the most extreme data point which is no more than coef times the length of the box away from the box. A value of zero causes the whiskers to extend to the data extremes (and no outliers be returned).

From these, we learn that the midline is the median of your data, with the upper and lower limits of the box being the third and first quartile1 (75th and 25th percentile) respectively. By default, the whiskers will extend up to 1.5 times the interquartile range from the top (bottom) of the box to the furthest datum within that distance. If there are any data beyond that distance, they are represented individually as points ('outliers').

To be explicit, they do not show standard deviations.

1. Note that determining the value for a quantile (e.g., the 25th percentile is potentially more complicated than people realize. There are at least nine different methods that have been discussed. For a nice overview, see @Glen_b's excellent answer here: Relation between Quintiles and the Arithmetic Mean.

This sums up the box plot and what each line represents.

• The ends of the whiskers may not be the minimum and maximum values. Jan 3, 2016 at 16:46
• true - there may be outliers Jan 3, 2016 at 16:49
• This answer is wrong. Jul 27, 2017 at 8:14
• I don't think this answer should have three upvotes - it is wrong as the ends of the whiskers do not necessarily go to the minimum and maximum.
– bob
May 26, 2021 at 0:40