MATLAB Answers

adding legend from a list in the loop divides the names

4 views (last 30 days)
farzad
farzad on 8 May 2020
Commented: farzad on 9 May 2020
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 :

  0 Comments

Sign in to comment.

Accepted Answer

Ameer Hamza
Ameer Hamza on 8 May 2020
Edited: Ameer Hamza on 8 May 2020
[ ] 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 Comments

Show 4 older comments
farzad
farzad on 9 May 2020
it still doesn't work in the app window yet. the problem with printPlot that I don't know if app designer supports
farzad
farzad on 9 May 2020
no the legend is ok, I was talking about the other question. maybe better to follow up there

Sign in to comment.

More Answers (0)


Translated by