legend imformation is incorrect

5 Ansichten (letzte 30 Tage)
Yussif M. Awelisah
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.

Akzeptierte Antwort

Star Strider
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
Yussif M. Awelisah
Yussif M. Awelisah am 8 Okt. 2019
I am grateful for kindness and support.
I hope you can try plotting the attached data. May be the previous data was same as the original data.
I used the code below but got the attached error.
figure
hp{1} = plot(Down','m');
hold on
hp{2} = plot(Upper','b');
hold off % <— Toggle ‘hold’ Off Here
xlabel('Wavelength');
ylabel('Intensity');
legend([hp{:}], 'Down Extraction','Upper Extraction');
title('FEMD Dual Position Extraction of DS');
Error using horzcat
Dimensions of matrices being concatenated are not consistent.
ccc.png
Star Strider
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.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Yussif M. Awelisah
Yussif M. Awelisah am 8 Okt. 2019
@Star Strider
@Walter Roberson
I am sincerely grateful. This worked for me and I am sincerely grateful for your loyalty and kindness.

Kategorien

Mehr zu 2-D and 3-D Plots finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by