Can I use box-and-whisker plots also for multimodal distribution or only for unimodal distribution?
The problem is that the usual boxplot* generally can't give an indication of the number of modes. While in some (generally rare) circumstances it is possible to get a clear indication that the smallest number of modes exceeds 1, more usually a given boxplot is consistent with one or any larger number of modes.
* several modifications of the usual kinds of boxplot have been suggested which do more to indicate changes in density and cam be used to identify multiple modes, but I don't think those are the purpose of this question.
For example, while this plot does indicate the presence of at least two modes (the data were generated so as to have exactly two) -
conversely, this one has two very clear modes in its distribution but you simply can't tell that from the boxplot at all:
Boxplots don't necessarily convey a lot of information about the distribution. In the absence of any marked points outside the whiskers, they contain only five values, and a five number summary doesn't pin down the distribution much. However, the first figure above shows a case where the cdf is sufficiently "pinned down" to essentially rule out a unimodal distribution (at least at the sample size of $n=$100) -- no unimodal cdf is consistent with the constraints on the cdf in that case, which require a relatively sharp rise in the first quarter, a flattening out to (on average) a small rate of increase in the middle half and then changing to another sharp rise in the last quarter.
Indeed, we can see that the five-number summary doesn't tell us a great deal in general in figure 1 here (which I believe is a working paper later published in ) shows four different data sets with the same box plot.
I don't have that data to hand, but it's a trivial matter to make a similar data set - as indicated in the link above related to the five-number summary, we need only constrain our distributions to lie within the rectangular boxes that the five number summary restricts us to.
Here's R code which will generate similar data to that in the paper:
x1 = qnorm(ppoints(1:100,a=-.072377)) x1 = x1/diff(range(x1))*18+10 b = fivenum(x1) # all of the data has this five number summary x2 = qnorm(ppoints(1:48));x2=x2/diff(range(x2))*.6 x2 = c(b,x2+b,.31+b,b-.31,x2+b,b) d = .1183675; x3 = ((0:34)-34/2)/34*(9-d)+(5.5-d/2) x3 = c(x3,rep(9.5,15),rep(10.5,15),20-x3) x4 = c(1,rep(b,24),(0:49)/49*(b-b)+b,(0:24)/24*(b-b)+b)
Here's a similar display to that in the paper, of the above data (except I show all four boxplots here):
There's a somewhat similar set of displays in Matejka & Fitzmaurice (2017), though they don't seem to have a very skewed example like x4 (they do have some mildly skewed examples) - and they do have some trimodal examples not in ; the basic point of the examples is the same.
Beware, however -- histograms can have problems, too; indeed, we see one of its problems here, because the distribution in the third "peaked" histogram is actually distinctly bimodal; the histogram bin width is simply too wide to show it. Further, as Nick Cox points out in comments, kernel density estimates may also affect the impression of the number of modes (sometimes smearing out modes ... or sometimes suggesting small modes where none exist in the original distribution). One must take care with interpretation of many common displays.
There are modifications of the boxplot that can better indicate multimodality (vase plots, violin plots and bean plots, among numerous others). In some situations they may be useful, but if I'm interested in finding modes I'll usually look at a different sort of display.
Boxplots are better when interest focuses on comparisons of location and spread (and often perhaps to skewness$^\dagger$) rather than the particulars of distributional shape. If multimodality is important to show, I'd suggest looking at displays that are better at showing that - the precise choice of display depends on what you most want it to show well.
$\dagger$ but not always - the fourth data set (
x4) in the example data above shows that you can easily have a distinctly skewed distribution with a perfectly symmetric boxplot.
: Justin Matejka and George Fitzmaurice, (2017),
"Same Stats, Different Graphs: Generating Datasets with Varied Appearance and Identical Statistics through Simulated Annealing".
In Proceedings of the 2017 CHI Conference on Human Factors in Computing Systems (CHI '17). Association for Computing Machinery, New York, NY, USA, 1290–1294. DOI:https://doi.org/10.1145/3025453.3025912
(See the pdf here)
There are multiple options for detecting multimodality with R. Data for the below charts was generated with three modes (-3,0,1). The boxplot is clearly outperformed by the others (the violin plot looks like it has different default kernel density settings), but none really distinguish between the 0 and 1 modes. There are really few reasons to use boxplots anymore in the computer age. Why throw out information?
dat <- c(rnorm(500, -3, 1), rnorm(200, 0, 1), rnorm(300, 1, 1)) par(mfrow=c(2, 2)) boxplot(dat, horizontal=TRUE, main="Boxplot") require(beanplot) beanplot(dat, horizontal=TRUE, main="Beanplot") require(viopoints) viopoints(dat, horizontal=TRUE, main="Viopoints") require(vioplot) vioplot(dat, horizontal=TRUE) title("Violin Plot")