legend(errorbars, {'5-15 Percent Exiting Agents', '25-35 Percent Exiting Agents','55-65 Percent Exiting Agents','x','y','z'},'Location','NorthWest');
给出错误:
使用图例时出错(第 120 行) 参数无效。键入“帮助图例”以获取更多信息。
>> errorbars
errorbars =
0.0011 0.0012 1.0012 2.0012 3.0012 4.0012
我不知道为什么会发生此错误。因为它有六个错误栏的 6 个标签!
另外,发布完整代码:
for k=1:2, %x-axis variables
for i=1:size(StringDes,2), %y-axis outputs
errorbar_index=0;
set(gcf, 'units','normalized','outerposition',[0 0 1 1]);
for j=1:3, % two loops for 6 errorbars
for z=1:2,
errorbar_index=errorbar_index+1;
filter2= (pe{z}<upp(j) & pe{z} >lowp(j));
dataset=Descriptors{z}{i};
var= Variables{z}(:,k);
y=dataset(filter2);
x=var(filter2);
if(k==2)
range=rangeValues_ks;
else
range=rangeValues_ke;
end
filter3=(ismember(x,range)) ;
[vals, ~, id] = unique(x(filter3));
m = accumarray(id, y(filter3), [], @mean);
s = accumarray(id, y(filter3), [], @std);
errorbars(errorbar_index)=errorbar(vals,m,s,colors(j), 'LineStyle',linestyle{z},'Marker',marker{z},'LineWidth',linewidth(z));
end
xlabel(StringVar(k));
ylabel(StringDes(i));
hold all;
end
filename=char(strcat(StringDesFileName(i),StringVarFileName(k)));
legend(errorbars, {'5-15 Percent Exiting Agents', '25-35 Percent Exiting Agents','55-65 Percent Exiting Agents','x','y','z'},'Location','NorthWest');
title('');
print(gcf,strcat(parent_folder,'/',filename),'-dpng','-r375' );
close gcf;
end
end