# BoxWhiskerChart Notched: how is the notch calculated?

I am aware of one convention for the uncertainty in a median:
it is 1.58 * IQR / Sqrt[n], where IQR is the inter-quartile range and n is the number of data points. This was proposed by McGill, Tukey, and Larsen in 1978, and is used by R for their boxplots. It corresponds roughly to a 95% confidence interval.

It seems that the "Notched" function in Mathematica's BoxWhiskerChart function is using a different calculation, but I have failed to find any information on what that calculation is.

• I believe the documentation says the fat part of the plot is bounded by the 1st and 3rd quartiles (Properties & Relations section). Am I missing something? – Sjoerd C. de Vries May 10 '15 at 19:35
• @SjoerdC.deVries Those are the boundaries of the box itself. I think the OP is referring to the limits of the notched part of the box, when you request the "Notched" option. – MarcoB May 10 '15 at 20:44

Update: You can control the median confidence interval using the suboption "MedianConfidenceIntervalParameter" of the option Method:

data = Table[RandomReal[BetaDistribution[a, 1.5], 100], {a, 1, 5, 1}];

opts = {{"Notched", {"MedianMarker", Purple}, {"MedianNotch", Orange}},
ImageSize -> 300,  ChartElementFunction -> "GlassBoxWhisker"};
bwc1 = BoxWhiskerChart[data[[1]], ## & @@ opts, PlotLabel -> Style["Default" , 16]];
bwcs = BoxWhiskerChart[data[[1]], Sequence @@ opts,
PlotLabel -> Style["MedianConfidenceIntervalParameter ->" <> ToString@#, 16],
Method -> {"MedianConfidenceIntervalParameter" -> #}] & /@
{1.7, .5, 1., 2., 3};

Row[{bwc1, bwcs[[1]]}]


Row[Rest@bwcs]


Note: The function ChartingiBoxWhiskerChart is the first function called in the TracePrint of BoxWhiskerChart[...]. One of its options is "MedianConfidenceIntervalParameter" with default value 1.7:

Options[ChartingiBoxWhiskerChart, "MedianConfidenceIntervalParameter"]


{"MedianConfidenceIntervalParameter" -> 1.7}

Original post:

The core function used rendering the box plots in BoxWhiskerChart is SystemBarFunctionDumpboxplot. You can see the code using

?? SystemBarFunctionDumpboxplot


The relevant line that determines the median interval is

SystemBarFunctionDumpmedianInterval =
(SystemBarFunctionDumpmedianConfIntPara 1.25 SystemBarFunctionDumpiqr)/
( 1.35 Sqrt[Length[SystemBarFunctionDumpdata]])


where SystemBarFunctionDumpiqr is the IQR and the default value for the parameter SystemBarFunctionDumpmedianConfIntPara is previously defined as

SystemBarFunctionDumpmedianConfIntPara = 1.7


So, the default value of the median interval parameter is

(1.7 1.25/1.35) IQR / Sqrt[n] = 1.574074 IQR / Sqrt[n]


The value of SystemBarFunctionDumpmedianConfIntPara is controlled by the option "MedianConfIntPara" but I could not figure out how this option is to be used in BoxWhiskerChart.

• This is brilliant (+1)! Would you mind sharing how you found out where to look for boxplot etc? I tried to dig around a bit, but came up empty. – MarcoB May 10 '15 at 20:46
• @MarcoB, thank you for the vote and kind words. I use the general spelunking method: use ?? **BoxWhisker* and click on some the results; found that SystemBarFunctionDumpboxplot` is called by few functions that inspected. I was lucky to bump into something that was relevant without going through a long chain of other function calls. – kglr May 10 '15 at 21:48
• Thank you! I will use this example as a study tool in spelunking, by trying to retrace your steps. I am curious to see how far I can get with this approach on my own, knowing a) that there is something to find; 2) what that something is already ;-) – MarcoB May 10 '15 at 22:06