9
$\begingroup$

Currently I am creating a box plot. I am new on the field of statistics and especially box plots. Find the picture following: enter image description here

On the y-axis find the number of messages. I have problems understanding what I see there. The plot is created by Matlab automatically. As I know there should be four quartile in a box plot. I see there only three. Probably this happened because of the value of the median (it is the green line). But I do not know what this means if a quartile is missing. Is somebody around here who can may be explain this and tell me some details, what you can read out of the plot?

$\endgroup$
10
  • $\begingroup$ You would better off for most purposes with a histogram or dot plot with a bin for each integer. Nothing stops you drawing that vertically or superimposing median and quartiles. Among several other limitations this design gives no information on the frequencies of 12 14 16 18 20 as observed values. $\endgroup$
    – Nick Cox
    Commented Sep 25, 2019 at 12:19
  • $\begingroup$ Question: it seems that only even integers appear in your data. Is that so and if it is why does that happen? $\endgroup$
    – Nick Cox
    Commented Sep 25, 2019 at 12:21
  • $\begingroup$ There are 3 quartiles, not 4. They define up to 4 bins (fewer in this case). $\endgroup$
    – Nick Cox
    Commented Sep 25, 2019 at 12:34
  • $\begingroup$ @NickCox the y axis is a number of messages. That is count data and explains the integers. $\endgroup$
    – Bernhard
    Commented Sep 25, 2019 at 12:59
  • $\begingroup$ Sure, I get that, as my first comment shows, but why only even integers? I see 26 20 18 16 14 12 10 8 6 4 being shown. Some odd integers may be hidden by the box; otherwise that looks like a pattern. $\endgroup$
    – Nick Cox
    Commented Sep 25, 2019 at 13:04

2 Answers 2

18
$\begingroup$

The median is probably identical to the first quartile, which is why they overlap. This tends to happen when you have a large proportion of identical, low values in the dataset. Here's an example that reproduces this pattern:

dat <- c(1,2,2,2,3,5,6)

median(dat)
## 2
quantile(dat, 0.25)
## 25% 
##  2 

boxplot(dat)

enter image description here You can read a basic introduction about how to interpret boxplots here. Though as Nick Cox points out below, its discussion of what are called 'outliers' is flawed and should be ignored. Outliers should not be deleted unless there is very strong reason to, such as a clear data recording error.

Note also that a boxplot is not a great way to display many datasets. I agree with Stephan Kolassa's recommendation of a beeswarm plot for small datasets and a violin plot/kernel density plot for larger ones.

$\endgroup$
2
  • 4
    $\begingroup$ The cited source follows a regrettably common practice of calling points that are shown individually by the name outliers. As the box plot here shows, such points are not necessarily outliers in any other strong statistical sense. This is more than which term should be used: many questions on CV — particularly from “data science” — show a belief that such points should be deleted before further analysis. $\endgroup$
    – Nick Cox
    Commented Sep 25, 2019 at 12:31
  • 1
    $\begingroup$ @NickCox Thanks, I agree with this criticism and should have caught that before linking to it. $\endgroup$
    – mkt
    Commented Sep 25, 2019 at 12:36
9
$\begingroup$

The "box" in a boxplot extends from the first to the third quartile, i.e., from the 25th to the 75th percentile. Visually, this means that your 25th percentile is around 6 messages, and your 75th percentile around 8.

In addition, boxplots indicate the median (i.e., the second quartile, or 50th percentile) using a horizontal line.

Of course, the median can coincide with a quartile. Good implementations therefore use a different color or line type for the median line. In the present case, we see that the bottom horizontal line is green. It is obviously plotted over the first quartile line. Thus, this is not only the first quartile, but simultaneously the median. Therefore, your median is also about 6.

You should be able to verify this from your data, by calculating the quartiles and the median.

$\endgroup$
2
  • 4
    $\begingroup$ (+1) All bang on, but I have seen box plots for small integer counts misinterpreted so often — people can’t or don’t want to think hard about ties and what they may imply — that I customarily recommend something else. $\endgroup$
    – Nick Cox
    Commented Sep 25, 2019 at 12:56
  • 2
    $\begingroup$ @NickCox: very true. I usually recommend a beeswarm plot overlaid to the boxplot if the number of points is "small or medium-sized", and a violin plot if it is "medium-sized or large". $\endgroup$ Commented Sep 25, 2019 at 13:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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