1

I was using the DataFrame.boxplot() function in Pandas, which I believe calls the matplotlib.pyplot.boxplot(). The documentation says that the default whisker length of these boxplots should be 1.5IQR, but I don't understand why the upper/lower whiskers of the same box are of different lengths in the plot. (I have not done any specific configurations)

Sorry I wanted to post the image but I do not have enough reputation, so I put it on a free image hosting site instead, link:

http://postimg.org/image/z0xtfg9gd/

Hasta Dhana
  • 4,699
  • 7
  • 17
  • 26
Pakwah
  • 79
  • 1
  • 7

3 Answers3

5

Sounds like a general misunderstanding of boxplots.

There are two reasons whiskers length vary from one boxplot to any other boxplot

  1. The IQRs for each of the datasets are different
  2. The whiskers extend only the outermost points within that Q1 - 1.5IQR and Q3 + 1.5IQR range. So if Q3 + 1.5*IQR = 75, but the max value of your sample is 70, the whisker is drawn at 70.

This answer gives a full explanation how boxplots are constructed including a drawing.

Joooeey
  • 3,394
  • 1
  • 35
  • 49
Paul H
  • 65,268
  • 20
  • 159
  • 136
4

Are you asking why the top whisker isn't the same length as the bottom? I think the whiskers are actually the lowest or highest data point within 1.5 IQR. So if there are no data points between Q3 and Q3 + 1.5 IQR, then the top whisker won't show up. For the one boxplot where the are outliers beyond the whiskers on both the top and the bottom, the whiskers do look about the same size.

Amy Teegarden
  • 3,842
  • 20
  • 23
0

The whiskers are of different length because the IQR can be different for each data set!

The Interquartile range holds 50% of all data, and thus is wider when the data is more widespread. Also, if all data points are within Q1 - 1.5*IQR and Q3 + 1.5*IQR, the whiskers will only be drawn up to these points, which will make them smaller too.

adrianus
  • 3,141
  • 1
  • 22
  • 41
  • Thanks for your reply, but I was trying to ask why the upper whisker and the lower whisker of the same box have different lengths. Sorry I wasn't clear enough in the original post. – Pakwah Jul 20 '15 at 21:06