matlab pareto 升级版

由于pareto 只能最多显示10列数据,及使用其他命令显示10组以外的数据时效果也不理想,(超过十没有坐标)。

此时我写了一个函数功能类似,感觉更加完善一点:

function ze=mypareto(a,b)
%作用:显示累加后所占总数据的百分比
%a:整形,为输入的数据列数。b:输入的1*a实际数据,格式:[12, 23, 23, 34,....]
y
=100*b/sum(b);
x
=1:a;
kk(
1)=y(1);
for index=2:a
kk(index)
=kk(index-1)+y(index);
end
bar(y);
hold on
set(gca,'xtick',0:1:25)%设置Y轴间隔自然用ytick,用法类推。其中gca代表Current axes handle(当前坐标轴句柄)
set(gca,'ytick',0:10:100)
grid on
%图像显示方格
plot(x,kk);
xlabel(
'Principal Component');
ylabel(
'Variance Explained (%)');
hold off

图像对比:

pareto:

mypareto:


posted @ 2011-08-29 11:34  小妖.OTZ  阅读(1183)  评论(0编辑  收藏  举报