# How does BoxWhiskerChart detect outliers?

BoxWhiskerChart can detect and show outliers:

SeedRandom[39]
BoxWhiskerChart[
RandomVariate[NormalDistribution[], 100],
"Outliers"
]


• What is the precise mathematical criterion used to decide if a point is an outlier?
• Can this criterion be tweaked?
• Is this criterion implemented by any documented built-in function?

iqrc = "IQRCoefficient" /. ChartElementData["BoxWhisker", "Options"];


1.5

fences = Quartiles[data][[{1, 3}]] + {-1, 1} iqrc InterquartileRange[data]

outliers = Select[Not @* Between[fences]] @ data


{-3.0844, -3.4005}

which matches the vertical coordinates of outlier glyphs:

Cases[BoxWhiskerChart[data, "Outliers", PerformanceGoal -> "Speed"],
Inset[_, {_, a_}] :> a, All]


{-3.0844, -3.4005}

• Does ChartElementData[..., "Options"] appear anywhere within the documentation? I cannot find it (though I did find it in other SE answers). Jan 15, 2020 at 8:25
• @Szabolcs, afaik it does not appear in documentation. I think I bumped into it using the spelunking trick: ClearAttributes[ChartElementData, {Protected, ReadProtected}]; ?? ChartElementData
– kglr
Jan 15, 2020 at 10:34
• I found one example in BarChart >> Options >> ChartElementFunction >> last example: ChartElementData["GradientRectangle", "Options"]
– kglr
Jan 15, 2020 at 10:39

It is actually in the help documentation as the last item. Outliers are 1.5 InterQuartileRanges (IQR) away from the nearest quartile and Far Outliers are 3 IQR distant.

• Indeed! It's under Properties and Relations. I found that, deleted the question, then undeleted when someone mentioned that they were just about to post an answer. Jan 15, 2020 at 7:38

In order to tweak this option:

BoxWhiskerChart[data, "Outliers",
ChartElementFunction ->
ChartElementDataFunction["BoxWhisker","IQRCoefficient" -> 3]
]