Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

5th & 95th percentile in BOXPLOT?

708 views
Skip to first unread message

Aditya Vaishya

unread,
Jul 24, 2011, 12:53:08 PM7/24/11
to
Hello,
I want to specify the 5th and 95th percentile in the BOXPLOT and the whiskers accordingly.
According to this thread the solution is simple:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/138804

in the new version of Matlab2010b the lines are not there.
Any clue how to resolve this issue?

Thanks.

Tom Lane

unread,
Jul 25, 2011, 10:52:59 AM7/25/11
to
> I want to specify the 5th and 95th percentile in the BOXPLOT and the
> whiskers accordingly. According to this thread the solution is simple:
> http://www.mathworks.com/matlabcentral/newsreader/view_thread/138804
>
> in the new version of Matlab2010b the lines are not there.

Yes, the boxplot function was substantially re-written since then. One thing
that was added was a collection of tags to the graphics elements so that you
can post-process the plot without modifying the toolbox function. So, while
the following might seem involved, I recommend it as a safer way to get what
you want.

-- Tom

x = gallery('normaldata',[100 5],0);
p = prctile(x,[5 95])
boxplot(x);

% Replace upper end y value of whisker
h = flipud(findobj(gca,'Tag','Upper Whisker'));
for j=1:length(h);
ydata = get(h(j),'YData');
ydata(2) = p(2,j);
set(h(j),'YData',ydata);
end

% Replace all y values of adjacent value
h = flipud(findobj(gca,'Tag','Upper Adjacent Value'));
for j=1:length(h);
ydata = get(h(j),'YData');
ydata(:) = p(2,j);
set(h(j),'YData',ydata);
end

% Replace lower end y value of whisker
h = flipud(findobj(gca,'Tag','Lower Whisker'));
for j=1:length(h);
ydata = get(h(j),'YData');
ydata(1) = p(1,j);
set(h(j),'YData',ydata);
end

% Replace all y values of adjacent value
h = flipud(findobj(gca,'Tag','Lower Adjacent Value'));
for j=1:length(h);
ydata = get(h(j),'YData');
ydata(:) = p(1,j);
set(h(j),'YData',ydata);
end

Aditya Vaishya

unread,
Jul 26, 2011, 8:50:09 AM7/26/11
to
"Tom Lane" <tl...@mathworks.nospam.com> wrote in message <j0k00c$ll4$1...@newscl01ah.mathworks.com>...
************************************

Thanks Tom.
It worked and is of great help :)

Aditya

0 new messages