If I have a set of data and I want to display it as a boxplot, when there are some outliers in the boxplot, we indicate outliers with a *. If there are two outliers having the same value, how to put that in the boxplot? Is it still *?

  • 1
    $\begingroup$ Could you be a little more specific? Are you asking about the input data to a boxplot (where you could of course have duplicate values) or about the output values a boxplot function may report? The last will probably depend on your software. For instance, the boxplot() function in R will report multiple identical outliers separately: boxplot(c(rnorm(100,0,1),5,5))$out yields two separate outliers of value 5. $\endgroup$ Nov 16, 2012 at 8:52
  • 1
    $\begingroup$ There are several possibilities. Some programs - especially older ones using test-based display - will use a '2', '3' etc to indicate how many values are there. Other programs will show two stars (or circles or whatever) together. $\endgroup$
    – Glen_b
    Nov 16, 2012 at 9:35
  • 1
    $\begingroup$ Are you asking about doing boxplots by hand or about how some software does this? As @Glen_b said, different software will do different things. $\endgroup$
    – Peter Flom
    Nov 16, 2012 at 11:51
  • $\begingroup$ @StephanKolassa: I think the point is that they are plotted over the top of each other, so you can't see that there's two. $\endgroup$
    – naught101
    Nov 22, 2012 at 5:56

2 Answers 2


I'll use R in proposing a solution. Let's simulate some data:

foo <- c(rnorm(100,0,1),5,5,5,7,7)

I see two possibilities. The first one would be to plot the boxplot and add sunflowerplots of the outliers:

bar <- boxplot(foo)

sunflowerplotted outliers

The second possibility is to plot the boxplot (which creates a single point for each outlier) and add additional points for additional outliers - which are jittered horizontally (edited as per @chl's excellent suggestion):

bar <- boxplot(foo,plot=FALSE)
points(jitter(rep(1, length(bar$out))), bar$out)

jittered outliers

Note that the first solution requires that your data are integers (otherwise you will run afoul of floating-point arithmetic, see question 7.31 in the R FAQ - in this case you will need to do some additional work to ensure R knows which floating point numbers should be treated as "equal").

  • 1
    $\begingroup$ (+1) I would say points(jitter(rep(1, length(bar$out))), bar$out) is shorter :-) $\endgroup$
    – chl
    Nov 22, 2012 at 10:25
  • $\begingroup$ @chl: yes, that would be shorter... but then we would have n+1 points where only n should be for n outliers with the same value: one from the original boxplot and n from overplotting the jittered points. This is why I used the cumbersome table() stuff. (It would be easier if there were a way to tell boxplot() not to plot the outliers.) Or am I mistaken? $\endgroup$ Nov 22, 2012 at 10:29
  • 1
    $\begingroup$ Yes sorry, I wrote quickly: check the outline= argument to boxplot(). (You'll need to manage the y-axis limits, though.) $\endgroup$
    – chl
    Nov 22, 2012 at 10:33
  • $\begingroup$ @chl: thank you, that definitely helps! I edited the original proposal. $\endgroup$ Nov 22, 2012 at 10:41

Late to the party, but "Don't do that then!" is sometimes a fair answer.

The box plot was a reinvention by John W. Tukey in the late 1960s of dispersion diagrams -- in geography literature from the 1930s -- and of range-bar plots -- in statistical literature from the 1940s. He supplied (in no particular order)

  1. a catchier name
  2. a sharp focus on being aware both of broad features such as level, spread, and shape and of specific details, especially wilder data points
  3. a rule of thumb for identifying individual points worth thinking about.

On #3 careful reading shows that Tukey tried various rules of thumb over several years of experiment. The rule now most often used -- plot as individual data points values that fall more than 1.5 IQR away from the nearer quartile -- was never more than one possible compromise. It's documented that he replied laconically to "Why 1.5?" with "1 is too small and 2 is too large". (I tend to prefer a rule such as: extend the whiskers to the $p$% and $(100 - p)$% quantiles.)

On #3 it is especially unfortunate that Tukey's exploratory purpose of identifying points to think about has in some quarters been perverted into an exclusion criterion for identifying bad data points that should be dropped from the dataset, or at least omitted from analyses.

It's worth underlining that Tukey's main context was quick and easy data plotting by hand with a minimum of work. Now it's naturally easy to plot if not all the data, then very many more than a box plot often shows -- and it's possible to do so without overwhelming the reader with detail. There is more than one way to do that, but here is a quantile plot of an example resembling that of @Stephan Kolassa, 100 points from a standard normal, 2 instances of 5 and 3 of 7. The box shown alongside is reduced to doing what it does best, showing by way of summary where the central half lies. The whiskers don't have much of a role, but I show them any way. Seeing repeated data points is not too hard. (I don't much favour sunflower plots, if only for the chicken-and-egg reason that as they aren't widely used, you have to explain them every time you use them.)

enter image description here

It's also entirely possible to superimpose the box and the quantile plot, as Emanuel Parzen suggested.

I used Stata, but something similar should be easy in your own favourite software. If not, you need new favourite software. (Having 2 5s and 3 7s, not vice versa, was a trivial error compared with emulating Stephan's code.)

set seed 2803 
set obs 105
gen whatever = cond(_n <= 100, rnormal(0, 1), cond(_n < 103, 5, 7))
ssc install stripplot 
stripplot whatever, yla(, ang(h)) cumul cumprob vertical iqr  box(barw(0.1)) boffset(-0.1) refline reflevel(median) aspect(1)

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.