Box Plot with Percentiles Known

조회 수: 5 (최근 30일)
Colin
Colin 2012년 3월 9일
I want to plot accuracy measures for an environmental variable, using the box plot approach. I have the error values / bounds for the 5, 25, 75, and 95th percentiles. All I want to do is show these error bounds using a box plot. I don't want box plot to calculate anything ... just produce the plot. Is there some way to do this in MATLAB ??
  댓글 수: 2
bym
bym 2012년 3월 9일
I don't suppose errorbar() helps you?
Laurens Bakker
Laurens Bakker 2012년 3월 9일
I've searched for this as well, without success...

댓글을 달려면 로그인하십시오.

채택된 답변

Oleg Komarov
Oleg Komarov 2012년 3월 10일
One approach is to draw the boxplot and then adjust it:
Say you have data
data = rand(100,2);
% Your 5 (1st row), 25, 75, 95 (last row) stats
s = [0.3 0.2; 0.4 0.42; 0.8 0.79; .89 .88];
% Calculate boxplot retaining handles
h = boxplot(data);
% Modify upper whisker's length
set(h(1,:),{'Ydata'},num2cell(s(end-1:end,:),1)')
% Modify lower whisker's length
set(h(2,:),{'Ydata'},num2cell(s(2:-1:1,:),1)')
% Modify upper whisker's endbar
set(h(3,:),{'Ydata'},num2cell(s([end end],:),1)')
% Modify lower whisker's endbar
set(h(4,:),{'Ydata'},num2cell(s([1 1],:),1)')
% Modify body
set(h(5,:),{'Ydata'},num2cell(s([2 3 3 2 2],:),1)')
% Median? (nothing specified, just invisible)
set(h(6,:),{'Visible'},{'off'})
% Outliers? (set the old ones to off and draw new ones)
set(h(7,:),{'Visible'},{'off'})
hold on
plot(1,.95,'+r',2,.1,'+r')
You could encapsulate these commands in a function or you could write a personalized boxplot, which way is best depends on the use you need of it.

추가 답변 (0개)

태그

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by