legend(errorbars, {'5-15 Percent Exiting Agents', '25-35 Percent Exiting Agents','55-65 Percent Exiting Agents','x','y','z'},'Location','NorthWest');
給出了錯誤:圖例錯誤在Errorbars Matlab的
錯誤使用圖例(線120) 參數無效。輸入'help legend'以獲取更多信息。
>> 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
如果您從'legend'調用中移除'errorbars'參數,它會起作用嗎? – schvaba986
所以你嘗試了我的建議? –
是的,解決了! Sry在之前回復。這個問題迷失了。 –