Multiple legands with semilogy

조회 수: 15 (최근 30일)
matt reister
matt reister 2011년 2월 9일
댓글: Muhammad Anjum Qureshi 2017년 12월 15일
I am using a loop to plot multiple plots in the same windows I would like to use mutliple legands to identify each data set. When i try to use legend('label1','label2') it says:
"Warning: Ignoring extra legend entries."
and when I attempt to call legend multiple times it simply replaces the old legend. I would prefer if there is a way i could call legend each time I add a new data set to the graph.

답변 (2개)

Gurudatha Pai
Gurudatha Pai 2011년 6월 18일
My guess is that you are probably using more strings in legend(); e.g: you are plotting only one array and passing two legend strings like below
plot(x,y);
legend('labels', 'label2');
you could probably do
h= figure();
plot(x,y)
hold on
plot(x, y2);
legend('labels', 'label2');
You could as well do something like this for each of your plots
h= figure();
hold on
plot(x,y);
legendmat = [legendmat; 'label1']
legend(legendmat)
% some other code
figure(h)
plot(x, y2);
legendmat = [legendmat; 'label2']
legend(legendmat)
% some other code
figure(h)
plot(x, y3);
legendmat = [legendmat; 'label3']
legend(legendmat)

SUDIP PODDAR
SUDIP PODDAR 2011년 8월 6일
??? Undefined function or variable 'legendmat'. give this error . what is the solution?
  댓글 수: 1
Muhammad Anjum Qureshi
Muhammad Anjum Qureshi 2017년 12월 15일
Add
legendmat = ''
only before first
legendmat = [legendmat; 'label1']

댓글을 달려면 로그인하십시오.

카테고리

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