Path: news.mathworks.com!not-for-mail
From: "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi>
Newsgroups: comp.soft-sys.matlab
Subject: Re: boxplot
Date: Tue, 18 Nov 2008 10:33:01 +0000 (UTC)
Organization: Tampere University of Technology
Lines: 55
Message-ID: <gfu5kt$fhe$1@fred.mathworks.com>
References: <gfk36r$bca$1@fred.mathworks.com> <gfr9uh$6lr$1@fred.mathworks.com> <gfsaa1$g5q$1@fred.mathworks.com>
Reply-To: "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1227004381 15918 172.30.248.37 (18 Nov 2008 10:33:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Tue, 18 Nov 2008 10:33:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 218565
Xref: news.mathworks.com comp.soft-sys.matlab:501379


"Lars Barring" <lars.barring@myworkplace.se> wrote in message <gfsaa1$g5q$1@fred.mathworks.com>...
> "Pekka Kumpulainen" <pekka.nospam.kumpulainen@tut.please.fi> wrote i
> > "Thamar van Esch" <thamarvanesch@gmail.com> wrote
> > > Is there a way to control the y-axis features in boxplot? I would like to change the 
> > > label ('Values' is default) and set the scale manually, but the regular 'set(gca,...)' 
> > > does not work for boxplot.
> > 
> > What is it exactly that doesn't work?
> > At least these do work:
> > boxplot(randn(100,3))
> > set(gca,'YLim',[-5 5], ...)
> > 'YTick',[-2 0 2], ...
> > 'YTickLabel',{'L-2' 'L0' 'L2'});
> 
> Well, I do not know specifically about the y axis labels but I had the same 
> experience with x axis labels. Maybe you were trying to have horizontal boxes?
> 
> Whichever, this is my experience:
> After considerable investigations it turned out that the x axis labels in my plot were 
> not actually x axis labels (in the ordinary sense), but rather text object that are 
> children to the "boxplot" hggroup (the normal x axis labels were just turned 
> off/empty). This is somehow controlled through a setappdata structure that I did not 
> really bother to analyse in detail. Then there were listeners that sort of prevented 
> me from adding normal x axis labels but instead directed some (but not all) of the 
> adjustments that I was trying to do to these text object. 
> 
> To cut a long and boring story short, I spent something like six hours (!!) of 
> concentrated work on creating a something like a publication quality boxplot 
> because of the most unintuitive construction of the boxplot object.
> 
> And, to try to draw some general conclusion out of this experience, this is not the 
> first time that I find Matlab plot objects difficult because of more or less hidden 
> 'functionality' (bug or feature??). Another example is the colorbar issue where 
> attempts to make it nice and always well placed and scaled directly interfere with 
> the possibility to tailor the layout to specific need.
> 
> 
> Lars

OK, this clears the situation. 
Yes, boxplot is one of those "nice" creatures who do a lot of things inside.
Legend is another one, I really burned my sleeves with it some time ago. Extremely slow, usually in wrong place, unnecessary line and text objects created inside. I wrote my own for that purpose (several releases ago).

You can give the labels in call
h=boxplot(...'Labels',...)
h will be a matrix of handles to the line objects (not mentioned in documentation)
The line objects also have tags that can be used to find their handles. 
But the Labels have no tag. You can find their handles among the children of the hggroup object, which is the only child of the axis:
 hcc = get(get(gca,'Children'),'Children');
Usually the lables are the first ones (in reverse order from right to left). The only ones of type text anyway: hl = findobj(hcc,'type','text')
Now you can set their properties.

One reason why they use separate text objects instead of XTickLabels (or Y..) might be that tixklabels dont support tex or rotating, which is an option in boxplot.
But yes, could be more clear. However most things can be specified in the input arguments of boxplot.