omit plot legend entries
30 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Leonard John
el 5 de En. de 2022
Comentada: Leonard John
el 5 de En. de 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 comentarios
Respuesta aceptada
Voss
el 5 de En. de 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'});
Más respuestas (0)
Ver también
Categorías
Más información sobre Legend en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

