Visualization/colorization of many outliers in a BoxWhiskerChart

Imagine a larger data set which I want to display using BoxWhiskerChart.

data = Flatten[{RandomReal[1., 10000], RandomReal[2., 2000]}];

BoxWhiskerChart[data, {"Median", {"MedianMarker", 1, Black}, {"Whiskers", Black},
{"Fences", 0.5, Black}, {"Outliers", "o", Black}}]


Since there are a lot of outliers I cannot visualize them properly - the potential reader only sees a thick black line. When I enlarge the outlier marker the whole thing does not get better at all.

BoxWhiskerChart[data, {"Median", {"MedianMarker", 1, Black}, {"Whiskers", Black},
{"Fences", 0.5, Black}, {"Outliers", Style["o", 100], Black}}]


Is there a way to colorize the outlier markers using something like ColorFunction (which did not work for me) in a way that the individual markers can be seen more distinctly (alternating black, gray etc.)?

Or would it even be possible to reduce the number of displayed outliers in a way that one can see/identify them better?

UPDATE

I have decided to display the data using DistributionChart which clearly has advantages of showing the actual value distribution of the data. But with this solution another problem arises (see here).

1 Answer

Until someone comes up with a less convoluted approach, you can post-process the output of BoxWhiskerChart to color and/or to downsample the outliers as follows:

data = Flatten[{RandomReal[1., 10000], RandomReal[2., 2000]}];

b1 = BoxWhiskerChart[data,
{"Median", {"MedianMarker", 1, Black}, {"Whiskers", Black}, {"Fences", 0.5, Black},
{"Outliers", Graphics[{RGBColor[0, 1, 0], Line[{{0, 0}, {1, 0}}]}]}},
ImageSize -> 400];

b2 = b1 /. InsetBox[GraphicsBox[{RGBColor[0, 1, 0], ___}, ___], ___] :> {}

epl = Cases[b1, ib : InsetBox[GraphicsBox[{ RGBColor[0, 1, 0], ___}, ___], ___] :>
(ib /. RGBColor[0, 1, 0] -> Hue[RandomReal[]]), {0, Infinity}];

bwcs = Partition[Prepend[Show[b2, Epilog->epl[[#]]]&@@@{{ ;; }, {;; ;; 10}, {;; ;; 50}}, b1], 2];
Grid[bwcs]


• This works very well for for a large number of closely spaced outliers. The different colorings enable situation-dependent visualisation. Thank you :)! – Kardashev3 Oct 5 '14 at 18:16