![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240397/image.png)
legend imformation is incorrect
2 次查看(过去 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.![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240393/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240393/image.png)
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/240397/image.png)
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!