legend for hold function
7 ビュー (過去 30 日間)
古いコメントを表示
Josefina Ottitsch
2019 年 2 月 27 日
コメント済み: Josefina Ottitsch
2019 年 2 月 27 日
Hello,
I have a problem with a function I am using in a script.
in my script I am letting my program run through 1 file. The file consists of around 200 different but similar measurements, each measurement consists of around 500 x and y values.
in my script I tell my program to only plot lets say every 30th measurement. Therefore, my desired function plots around 200/30 = 6 graphs. I am using hold, so these 12 graphs are in one diagram.
My problem: I have difficulties setting up my legend.
currently the program looks like this:
for e=1:6
ee(e)=30*e
for i=1:length(ee)
legendstr{i}=num2str(ee(i));
legend('DisplayName','Measurement',legendstr)
hold all
end
end
while using this method, my legend only consists of the numbers 30 60 90 120 150 180 written downwards. But I cannot manage to write Measurement 30 Measurement 60 ... and so on
Does anyone know how to do this?
Thank you for the support!
0 件のコメント
採用された回答
Alex Mcaulley
2019 年 2 月 27 日
I think there is no 'DisplayName' property for a legend, it is aproperty of a chart, but you can do the same as you want just putting
for e=1:6
ee(e)=30*e
for i=1:length(ee)
legendstr{i}=['Measurement' num2str(ee(i))];
legend(legendstr)
hold all
end
end
Another option is setting in your plots the 'DisplayName' property. For example:
for e=1:6
ee(e)=30*e
plot(x,y,'DisplayName',['Measurement' num2str(ee(e))])
hold on
end
legend('show')
その他の回答 (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!