필터 지우기
필터 지우기

adding legend from a list in the loop divides the names

조회 수: 2 (최근 30일)
farzad
farzad 2020년 5월 8일
댓글: farzad 2020년 5월 9일
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
Ameer Hamza
Ameer Hamza 2020년 5월 9일
You mean the legend does not work correctly?
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