Brownian thought space

Cognitive science, mostly, but more a sometimes structured random walk about things.

My Photo
Location: Rochester, United States

Chronically curious モ..

Wednesday, October 06, 2010

Matlab boxplot notch "error" resolved

Use Matlab? Try this:
>> load carsmall
>> boxplot(MPG,Origin,'notch','on')
See something weird? Something that looks like this image with the boxes folded over? It's been driving me crazy for a while; I thought I'd broken Matlab somehow; till I discovered this little documentation. Essentially, before R2008b, the notches were truncated to the edges of the box. Since that's wrong, in the sense that the notches (robust estimates of the median) could extend beyond the box edges, Matlabbers fixed this, so now the notches go to wherever they please; but sometimes it makes the figures look weird.
From the Mathworks website:
  • For small groups, the 'notch' parameter sometimes produces notches that extend outside of the box. In previous releases, the notch was truncated to the extent of the box, which could produce a misleading display. A new value of 'markers' for this parameter avoids the display issue.

As a consequence, the anova1 function, which displays notched box plots for grouped data, may show notches that extend outside the boxes.

For comparison, the second figure is how boxplot used to work.