Box Plot with Percentiles Known

4 vues (au cours des 30 derniers jours)
Colin
Colin le 9 Mar 2012
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 commentaires
bym
bym le 9 Mar 2012
I don't suppose errorbar() helps you?
Laurens Bakker
Laurens Bakker le 9 Mar 2012
I've searched for this as well, without success...

Connectez-vous pour commenter.

Réponse acceptée

Oleg Komarov
Oleg Komarov le 10 Mar 2012
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.

Plus de réponses (0)

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by