legend imformation is incorrect
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Yussif M. Awelisah
am 29 Sep. 2019
Kommentiert: Star Strider
am 8 Okt. 2019
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 Kommentare
Akzeptierte Antwort
Star Strider
am 29 Sep. 2019
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 Kommentare
Star Strider
am 8 Okt. 2019
@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.
Weitere Antworten (1)
Siehe auch
Kategorien
Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!