Legend in for loop
3 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I have a problem.
I want to plot a figure in for-loop of unknown number of values.
figure
cc=hsv(12);
for p=2:length(mydistances)
i(p)= plot(x,y(:,p),'o','color',cc(p,:)); hold on;
legend(i(p), ['Distance: ',num2str(mydistances(p))])
end
but this only plots 1 legend bar when I have length(mydistances)-1 number of data.
How can I arrange this so it plots a legend for each dataset?
0 件のコメント
回答 (1 件)
laurie
2012 年 10 月 15 日
if you know mydistance, you can generate legend names in the for loop, than add a legend(legend_name(1), legend_name(2)....) after the for loop.. i don't know of any better way of doing this
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Legend についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!