legend imformation is incorrect
조회 수: 3 (최근 30일)
이전 댓글 표시
Please I am plotting the data attached with just the simple code below but the legends repeats the first color for the second plot.
plot(DownExtraction','m');
hold on
plot(Upperextraction','b');
xlabel('Wavelength');
ylabel('Intensity');
legend('Down Extraction','Upper Extraction');
title('FEMD Dual Position Extraction of DS');
Please your help wil be appreciated.
댓글 수: 0
채택된 답변
Star Strider
2019년 9월 29일
You must be plotting something else that is not in the code you posted or the data you attached.
This code:
D1 = load('Upper extraction.mat');
UpperExtraction = D1.DS_DATA_ODU;
D2 = load('Down Extraction.mat');
DownExtraction = D2.DS_DATA_ODD;
plot(DownExtraction','m');
hold on
plot(UpperExtraction','b');
xlabel('Wavelength');
ylabel('Intensity');
legend('Down Extraction','Upper Extraction');
title('FEMD Dual Position Extraction of DS');
produces this plot:
That appears correct to me.
Note that the line at zero intensity does not appear.
The problem may be that you are plotting something else afterwards, with the hold state still on.
Try this instead:
figure
plot(DownExtraction','m');
hold on
plot(UpperExtraction','b');
hold off % <— Toggle ‘hold’ Off Here
xlabel('Wavelength');
ylabel('Intensity');
legend('Down Extraction','Upper Extraction');
title('FEMD Dual Position Extraction of DS');
Experiment to get the result you want.
댓글 수: 11
Star Strider
2019년 10월 8일
@Walter — Thank you!
@Yussif Moro Awelisah — Your data are confusing and not well documented.
This worked for me when I tried it (with the ‘Down.mat’ and ‘Upper.mat’ files attached to your latest Comment):
figure
hp1 = plot(Down','m');
hold on
hp2 = plot(Upper','b');
hold off % <— Toggle ‘hold’ Off Here
xlabel('Wavelength');
ylabel('Intensity');
legend([hp1(1),hp2(1)], 'Down Extraction','Upper Extraction');
title('FEMD Dual Position Extraction of DS');
You need to experiment with the ‘hp’ handles (as I have called them here) to be sure they correspond with the data you are plotting. I have no idea what they are or how you calculated them, so I just experimented until I got them to work. If they are the reverse of what they should be, reverse the order of the ‘hp’ elements in the legend handle vector (between the square brackets []).
Note that ‘Down’ is a (6x500) double matrix, and ‘Upper’ is a (4x500) double matrix. You appear to be plotting the same data (or approximately the same data) several times.
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!