Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I was trying to adapt the BoxWhiskerChart to obtain a minimalistic quartile plot, like this:

Quartile plot

What I obtained is the plot below that is, however, unsatisfying; the median markers should be circles, but they are instead slightly squared.

Quartile plot with wrong median markers

The code:

data = Table[
   RandomVariate[NormalDistribution[μ, 1], 100], {μ, 
    RandomInteger[{-2, 2}, 10]}];
filledCircle[size_] := Graphics[{Black, Disk[]}, ImageSize -> size];
BoxWhiskerChart[data,
  {{"Whiskers", Black},
   {"MedianMarker", filledCircle[10], Black},
   {"Fences", None}},
  ChartBaseStyle -> White,
  Frame -> False,
  Method -> {"BoxRange" -> (Quantile[#, 
        Range[0, 1, 1/4], {{1/2, 0}, {0, 1}}] &)}
  ]

As an alternative, I've tried to rasterize the circles; the shape is now correct, but we get a lateral shift of the median marker.

filledCircle[size_] := Rasterize[Graphics[{Black, Disk[]}, ImageSize -> size]];

Quartile plot with shift

Does anyone have a better approach or solution? Or should I just build my own function?

share|improve this question
    
Not sure how this helps, when I run your code the circles are definitely more circular than the ones shown in your first example, when zoomed to 300%, the left rightish quadrant has slightly octagonal edges, but the rest is circular. I'm on 8.0.4 on Linux. –  image_doctor Oct 31 '12 at 19:05
    
@image_doctor If I set filledCircle[50] then they look more circular, but I'm looking for a solution with smaller circles. –  VLC Oct 31 '12 at 19:12
1  
Does filledCircle[size_] :=Style[Graphics[{Black, Disk[]}, ImageSize -> size], Antialiasing -> True] give something close to what you need? –  kguler Nov 1 '12 at 0:46

2 Answers 2

up vote 5 down vote accepted

The disks aren't getting antialiased. (This is probably leaking from turning off antialiasing for the lines and rectangles.)

If you turn antialiasing back on:

filledCircle[size_] := 
    Graphics[{Black, Style[Disk[], Antialiasing -> True]}, 
        ImageSize -> size]

it should look better:

enter image description here

share|improve this answer
    
Thanks! It looks like that the problem is solved. I like your solution better, because it gives more freedom in defining the shape of the marker than using symbols like \[FilledCircle] and the like. –  VLC Nov 1 '12 at 8:34

I would use a FilledCircle rather than creating the Disk:

data = Table[RandomVariate[NormalDistribution[μ, 1], 100], {μ, 
RandomInteger[{-2, 2}, 10]}];


BoxWhiskerChart[data,
                {{"Whiskers", Black},
                {"MedianMarker", Style[\[FilledCircle], 45], Black},
                {"Fences", None}},
                ChartBaseStyle -> White,  Frame -> False,  
                Method -> {"BoxRange" -> 
                (Quantile[#,Range[0, 1, 1/4], {{1/2, 0}, {0, 1}}] &)}
                ]

Here is an example with the typical format overlaid:

Show[
      BoxWhiskerChart[data,
                     {{"Whiskers", Black},
                     {"MedianMarker",Style[\[FilledCircle], 30], Black},       
                     {"Fences", None}},
                     ChartBaseStyle -> White, Frame -> False, 
                     Method -> {"BoxRange" ->
                    (Quantile[#,Range[0, 1, 1/4], {{1/2, 0}, {0, 1}}] &)}],
      BoxWhiskerChart[data, {{"Fences", None}},ChartBaseStyle ->Opacity[.75]]
   ]

enter image description here

share|improve this answer
    
But those are also shifted. –  VLC Oct 31 '12 at 19:09
    
what operating system are you using VLC? –  chuy Oct 31 '12 at 19:20
    
@chuy Os X 10.6.8 –  VLC Oct 31 '12 at 19:22
    
Changed to a filled circle. Looks better now I think. –  David Slater Oct 31 '12 at 19:27

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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