adding legend from a list in the loop divides the names

3 次查看(过去 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 :

采纳的回答

Ameer Hamza
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 个评论
farzad
farzad 2020-5-9
no the legend is ok, I was talking about the other question. maybe better to follow up there

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by