6
$\begingroup$

Although I'm fairly new to box plots, I thought I had got the hang of them, until I came upon this one today. I don't know what to make of that bottom "whisker" drawn inside the box.

enter image description here

This population is composed by only four values: 16.5, 17.14, 13.5, 16.75

Granted, the small size of this population is probably not ideal for this kind of diagram. But this is just one among several ones that I'm plotting, and the others make a bit more sense.

My question is two-fold:

  1. Is this even a valid representation or is the software that I'm using to draw it misbehaving? (I'm using python and matplotlib)
  2. If it is valid, how do I go about interpreting it?

Edit:

Including a figure created with a whis=3 parameter (see answers below):

enter image description here

$\endgroup$
  • 2
    $\begingroup$ How does it define its boxplots? $\endgroup$ – Glen_b Mar 10 '13 at 1:17
  • 3
    $\begingroup$ Boxplots should not have whiskers within their interiors, period. Although that first figure may have some logical explanation, it's either an error or it's not a boxplot. $\endgroup$ – whuber Mar 13 '13 at 6:30
  • 1
    $\begingroup$ @whuber: Several years ago, I encountered 'ingrown whiskers' in Minitab with samples of size 7. A query to Minitab tech staff yielded a reply insisting that is what "Tukey intended," not bad code. Minitab code is not open, so I couldn't check. May have something to do with using 'fourths' instead of 'quartiles'. $\endgroup$ – BruceET Mar 5 '17 at 9:29
12
$\begingroup$

It is impossible to know without knowing more about what your software thinks is the right way to draw a box and whisker plot. It is even more difficult without a numeric scale to anchor the results on. Regardless, there are a number of different guidelines in this regard (in general). However, we can always resort to reading the documentation

  • boxes: the main body of the boxplot showing the quartiles and the median’s confidence intervals if enabled.
  • medians: horizonal lines at the median of each box.
  • whiskers: the vertical lines extending to the most extreme, n-outlier data points.
  • caps: the horizontal lines at the ends of the whiskers.
  • fliers: points representing data that extend beyone (sic) the whiskers (outliers).

Given the values of 16.5, 17.14, 13.5, and 16.75, the value of 13.5 is being treated as a 'flier'. The boxes are stretching from Q1 to Q3. The horizontal line is the median (aka Q2). The exact calculation of these values has a number of different approaches, but I'll just grab the handy values from R (quantile defaults) of 15.75 for Q1, 16.625 for Q2, and 16.8475 for Q3. Although the documentation cited above is unclear, it appears that the whiskers and caps extend to the most extreme, n-outlier data points excluding the 'fliers' (more on this later). Therefore, we can expect them to extend from 16.50 to 17.14. That is, they will extend to a value closer to the median than Q1 (at the bottom) and slightly beyond Q3 (at the top)... which is exactly what we see.

However, given the circular definition of whiskers and fliers... you have to look further up in the docs to see that whiskers are "a function of the inner quartile range. They extend to the most extreme data point within ( whis*(75%-25%) ) data range" where 'whis' has a default of 1.5. Combining these sources of information, we can see that whiskers would plot points 1.5 times the interquartile range, but they stop at the most extreme data point inside that range. Data points beyond that range are dubbed fliers and plotted as such.

So, in response to the second question it is 'valid'...it isn't my preferred way of seeing boxplots drawn, but that doesn't make it invalid. As I mentioned there is no one convention in this regard. So long as you know what the boxplot is drawing, and it draws it in that way - then it is at least reliable. Valid will be a value judgement you have to make for yourself.

My descriptions above, plus the docs should help you interpret your boxplot, but just in case:

  • Central Line: Median
  • Edges of Boxes: Q1 and Q3
  • Limits of Whiskers: The minimum and maximum values inside the inflated inter-quartile range (e.g. whis*(75%-25%) where whis defaults to 1.5)
  • Little plus signs: 'fliers', data-points beyond the limits of the whiskers
$\endgroup$
  • 1
    $\begingroup$ As an aside, I guess it is worth noting that there are many different ways of calculating Q1 and Q3 (at least 10 different methods in R alone). With larger samples agreement between them seemed (last time I glanced at it ad hoc) to be high. But with small sample sizes you can end up with fairly divergent numbers. $\endgroup$ – russellpierce Mar 10 '13 at 1:56
  • 2
    $\begingroup$ +1 Tukey's original boxplots were oriented towards pen-and-paper calculations and thus were based on the "hinges" (or "fourths") rather than quartiles. The hinges are medians of the two sets of data created by splitting the original batch into two equal-sized pieces at the median (including the median in both pieces when there is an odd number of values). This ties them more reliably to actual data values than many of the interpolated quantiles in R. $\endgroup$ – whuber Mar 13 '13 at 6:25
8
$\begingroup$

In R I've done the boxplot and plotted the individual points so you can see what it's doing:

> x<-c(16.5, 17.14, 13.5, 16.75)
> boxplot(x,boxwex=.2)
> points(x~rep(1,4),pch="x",col=2)

boxplot of data

As you see, it's not like the one you have.

In particular, after I stretch your bitmap out to approximately match the range (assuming the range of the two matches!), the box you have is shorter, as well as the whisker being inside the box.

boxplot comnparison

You need to check how they've defined the boxplot (definitions vary - but I think they're not using Tukey's definition of how hinges or whiskers work).

I've played about in various ways but I can't work out for sure how they're getting their hinges. They seem to be half the distance from the median that they should be.

(Aside from a different definition, it may be that their code simply assumes there's always more than four points somewhere in it, and that maybe has caused a problem.)

$\endgroup$
  • 2
    $\begingroup$ Your stretch demo also nicely demonstrates my explanation following from the documentation of his function. $\endgroup$ – russellpierce Mar 10 '13 at 1:45
  • $\begingroup$ Nevermind, boxplot.stats uses stats::fivenum which calculates the inter-quartile range differently than IQR. $\endgroup$ – russellpierce Mar 10 '13 at 1:52
  • 1
    $\begingroup$ @RussellS.Pierce Gee, a lot happened while I was playing with that. Thanks for the comments. $\endgroup$ – Glen_b Mar 10 '13 at 1:54
  • $\begingroup$ I've included a new diagram (see question) generated using whis=3. My understanding is that this increases the threshold above which a value is considered a flier. The result looks very close to your diagram generated with R! $\endgroup$ – Filipe Correia Mar 10 '13 at 22:25
  • 3
    $\begingroup$ @ Russell: "median(x)-(IQR(x)*1.5)" No, you want Q1-1.5*IQR, not median. $\endgroup$ – Jon Peltier Apr 1 '13 at 12:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.