adding legend from a list in the loop divides the names
2 ビュー (過去 30 日間)
古いコメントを表示
Hi all
I want to add the six plots in one plot a legend. which I have defined as :
Ls=['L1','L2','L3','L4','L5','L6'];
for c=1:6
plot3(v(:,1),v(:,2),v(:,3),colorcode(c),'DisplayName',Ls(c))
hold on
end
when I do this , the legend gets like :
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/291515/image.png)
0 件のコメント
採用された回答
Ameer Hamza
2020 年 5 月 8 日
編集済み: Ameer Hamza
2020 年 5 月 8 日
[ ] is concatenates the char datatypes. You need to use cell data type to keep them separate.
Ls={'L1','L2','L3','L4','L5','L6'};
for c=1:6
plot3(v(:,1),v(:,2),v(:,3),colorcode(c),'DisplayName',Ls{c})
hold on
end
7 件のコメント
その他の回答 (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!