9
$\begingroup$

If I want to make a horizontal boxplot (with outliers) for y:

y = {5.5, 5.61, 4.88, 5.07, 5.42, 5.55, 5.36, 5.29, 5.58, 5.65, 5.57, 
5.53, 5.62, 5.29, 5.44, 5.34, 5.79, 5.1, 5.27, 5.39, 5.42, 5.47, 
5.63, 5.34, 5.46, 5.3, 5.75, 5.68, 5.85};

I could use BoxWhiskerChart[y, "Outliers", BarOrigin -> Left], which works well. output
But if I also want the median line (or other features), there is a problem.
For example, using

BoxWhiskerChart[y, "Outliers", "Median", BarOrigin -> Left]

will give the following error message error
It seems Mathematica only allows one bwspec specification, and my question is: is that possible to have multiple bwspec?

$\endgroup$

3 Answers 3

6
$\begingroup$

In V10 the median marker is supplied by default, So the following will give you what you want.

BoxWhiskerChart[y, "Outliers", BarOrigin -> Left]

basic-chart

However, as Brett Champion has pointed out in his answer, to have more than one specification requires all but the first specification to given in a more complete form. This is discussed, perhaps not a clearly as it could be, in the documentation for BoxWhiskerChart. Here is an example of a fancier customization.

BoxWhiskerChart[
  y, 
  {"Outliers", {"MedianMarker", None}, {"MeanMarker", .5, Black}, {"MeanDiamond", .5, Red}}, 
  BarOrigin -> Left]

fancy-chart

$\endgroup$
1
  • $\begingroup$ Thank you for your thorough answer. $\endgroup$
    – user13473
    Jan 10, 2015 at 23:28
4
$\begingroup$

Not presently, although you can add individual items:

BoxWhiskerChart[y, {"Outliers", {"MedianMarker", 1, Red}}, BarOrigin -> Left]

enter image description here

$\endgroup$
3
  • $\begingroup$ But technically that is not bwspec right? $\endgroup$
    – user13473
    Jan 10, 2015 at 22:53
  • $\begingroup$ It is, actually. It's an example of the last form in the bwspec table: {name, {elem1, val1, ...}, ...}. $\endgroup$ Jan 10, 2015 at 23:06
  • $\begingroup$ but then why I can't just use "Mean" or "Median"? $\endgroup$
    – user13473
    Jan 10, 2015 at 23:13
1
$\begingroup$

The following form of bwspec works in both Version 9:

BoxWhiskerChart[y, {{"Outliers"}}, BarOrigin -> Left]

enter image description here

and Version 10:

enter image description here

So does

BoxWhiskerChart[y, {"Median", {"Outliers"}}, BarOrigin -> Left]
(* same picture *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.