omit plot legend entries
35 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Leonard John
am 5 Jan. 2022
Kommentiert: Leonard John
am 5 Jan. 2022
Within a loop I am creating fittings for a set of data. At the same time I am plotting the fitting curves and the data set with markers. How do I prevent the markers and small dots from showing within the legend? I only want the line color for each curve fitting to show up. There is one legend entry for each fit.
Thanks in advance!

0 Kommentare
Akzeptierte Antwort
Voss
am 5 Jan. 2022
One way is to store the handles to your lines as you create them and make a legend based on a subset of the lines:
figure();
my_lines = [];
my_lines(end+1) = plot(1:10);
hold on
my_lines(end+1) = plot(2:11);
my_lines(end+1) = plot(3:12);
legend(my_lines([1 3]),{'first' 'third'});
A similar way is to only store those handles you want to use in the legend:
figure();
my_lines = [];
my_lines(end+1) = plot(1:10);
hold on
plot(2:11);
my_lines(end+1) = plot(3:12);
legend(my_lines,{'first' 'third'});
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!

