6
$\begingroup$

BoxWhiskerChart draws a box-and-whisker summary of the distribution of the input data.

mma-boxwhisker

I would like to show the 2nd, 25th, 50th (the median), 75th, and 98th percentages of the input data.

Is it possible to user-define the percentages for lower/upper whisper/fence in BoxWhiskerChart?


data = Table[RandomVariate[NormalDistribution[RandomInteger[5], 1], 100], {2}];
BoxWhiskerChart[data, "Outliers"]
$\endgroup$
3
  • $\begingroup$ You want the 2% and 98% to replace the min and max? or to show in addition to them? $\endgroup$
    – Jason B.
    Feb 24 '16 at 9:54
  • 1
    $\begingroup$ A related question. $\endgroup$
    – J. M.'s torpor
    Feb 24 '16 at 9:56
  • $\begingroup$ @JasonB To replace the min and max. Thanks for your answer below. $\endgroup$
    – hengxin
    Feb 24 '16 at 12:35
8
$\begingroup$

Using Brett's answer, we can do it like this

BoxWhiskerChart[data, 
  Method -> {"BoxRange" -> (Quantile[#, {2/100, 1/4, 1/2, 3/4, 
         98/100}, {{1/2, 0}, {0, 1}}] &)}] /. {"min" -> "2%", 
  "max" -> "98%"}

enter image description here

Problem with Outliers

For some reason changing the "BoxRange" method has the effect of removing some, but not always all, of the plotted outliers,

data = RandomVariate[
   NormalDistribution[RandomInteger[5], 1], {5, 100}];
BoxWhiskerChart[data, "Outliers"]
BoxWhiskerChart[data, "Outliers", 
  Method -> {"BoxRange" -> (Quantile[#, {2/100, 1/4, 1/2, 3/4, 
         98/100}, {{1/2, 0}, {0, 1}}] &)}] /. {"min" -> "2%", 
  "max" -> "98%"}

enter image description here

This seems odd to me, because the definition of an outlier from this page would lead me to believe that a data point is an outlier if it is more than 1.5 times the interquartile range (the difference between the 75% and 25% values) lower than the 25% value. Since we didn't change those levels I would naively think the definition of an outlier should remain constant.

$\endgroup$
1
  • $\begingroup$ How do you put two bar plots in one figure? - - I reproduce two BoxWhiskerPlots in my System but cannot get them to the same plot. $\endgroup$ Sep 27 '16 at 10:33

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