Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to draw a custom BoxWhiskerChart with alternative values determining fences. I have data that has a lot of outliers and I have to compare it to another chart that has 10-90th percentile instead of standard min/max.

How would I go about it?

share|improve this question
Hi ! Do you have any code you can share with us ? – Sektor Jul 16 '14 at 21:59
Hi,data = RandomVariate[NormalDistribution[0, 1], 200]; BoxWhiskerChart[data] is the function I am using. Nothing more fancy about it. I am wondering if there is a way to modify the specification of what is a fence - ie instead of min-max - I would like it to be 10-th and 90th percentile. – jps Jul 16 '14 at 22:07
I would imagine it is possible to draw boxes, I am not sure how to use mathematica function draw[] to plot fences. – jps Jul 16 '14 at 22:10

With the data beeing

data = RandomVariate[NormalDistribution[0, 1], 200];

the range of the box specified to be one sigma (approx. 68.3 %tile range) by


and a limit for the fences defined to be 10 %

fencesLimit = 0.1

we can plot a BoxWhiskerChart using:

BoxWhiskerChart[data, "Median", Method -> "BoxRange" -> (Quantile[#, {fencesLimit, (1 - sigma)/2, 1/2, (1 + sigma)/2, 1 - fencesLimit}, {{1/3, 1/3}, {0, 1}}] &)]

This BoxWhisker is median centered, has a box range of one sigma, a lower fence at the 10 percentile, and an upper fence at the 90 percentile.
You can find in the documentation of Quantile how to choose another centering.

Here a plot of this BoxWhiskerChart:

enter image description here

With some additional styling and as a function with optional arguments:

bwChart[data_, br_: Erf[1/Sqrt[2]], flimit_: 0.1] := 
   {{"MedianMarker", 1, Directive[Thickness[0.01], Blue]}, {"MedianNotch", 0.5, Gray}},
   Method -> "BoxRange" -> (Quantile[#, {flimit, (1 - br)/2, 1/2, (1 + br)/2, 1 - flimit}, {{1/3, 1/3}, {0, 1}}] &), 
   BarSpacing -> None, AspectRatio -> 0.7, BarOrigin -> Left, 
   ChartElementFunction -> "GlassBoxWhisker", ChartStyle -> 6]

enter image description here

share|improve this answer
(+1) Thank you! Spent hours to make BoxRange work as an option :) – kglr Jul 17 '14 at 2:08
This is fantastic. Thank you for the clear explanation! – user18593 Jul 17 '14 at 22:41

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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