The line on the legend are not showing
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Romain
am 29 Nov. 2024
Bearbeitet: Walter Roberson
am 29 Nov. 2024
When i try plotting a legend i end up with only the names of the curves. But when i change the type of line of my curves like if i put . or o, it is showing on my graph but not for a continuous line. i tried a few different way to put the legend, manually or just trusting matlab but it doesn't work.
Here's my code
a_1 = plot(X_1,Y_1, 'b-', 'DisplayName', "Onde incidente");
hold on ;
a_2 = plot(X_2, Y_2,'r-', 'DisplayName', "Onde transmise");
title("Signal experimental Mousse G");
legend show;
xlabel("temps (s)");
ylabel("amplitude");
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 29 Nov. 2024
Bearbeitet: Walter Roberson
am 29 Nov. 2024
What you describe sounds as if either X_1 or Y_1 are scalars. In such a case, requesting . or o will draw markers, but there would be no finite (x,y) pairs to draw lines between.
Lower probability is if X_1 or Y_1 happens to be such that it has infinite or nan entries between every finite entry.
x = 1:5;
y = [1 nan inf 4 nan];
subplot(2,1,1)
plot(x,y)
xlim([0 5]); ylim([0 5])
subplot(2,1,2)
plot(x,y,'o-')
xlim([0 5]); ylim([0 5])
The first plot does not show any lines because lines are only drawn if there are adjacent finite coordinates.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Legend 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!
