Matlab中的Boxplot

时间:2015-03-11 13:22:14

标签: matlab boxplot

我想更改箱线图中的分位数,以便上部晶须是第95百分位数,而较低的晶须是第5百分位数。我尝试了以下代码(见下文),但它没有调整异常值。任何帮助,将不胜感激。谢谢!

boxplot(x);
p = prctile(x,[5 95]);

% 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 

0 个答案:

没有答案