5
$\begingroup$

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}}]

Mathematica graphics

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}}]

Mathematica graphics

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).

$\endgroup$
8
$\begingroup$

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]

enter image description here

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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