Box Plot with Percentiles Known

10 ビュー (過去 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