legend dynamically updated
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Chiara Modenese
el 21 de Mzo. de 2011
Comentada: Moritz Stich
el 31 de Mzo. de 2022
Hi, my task would be to have a legend which is update dynamically as I loop over some data extracted from different files and I add them to a same plot, for instance. To put it better, I would like to "append" a label to my legend every time I update my plot. Would you know how to do it?
Chiara
4 comentarios
Respuesta aceptada
Paulo Silva
el 21 de Mzo. de 2011
clf
clc
hold all
x=0:0.01:2*pi;
b=zeros(5);
for a=1:5
b(a)=plot(x,sin(a*x));
legend(b(1:a))
pause(1) %just to see it being draw
end
Alternative with choosen names for each plot
clf
clc
hold all
x=0:0.01:2*pi;
b=zeros(5);
c={'one','two','three','four','five'};
for a=1:5
b(a)=plot(x,sin(a*x));
legend(b(1:a),c(1:a))
pause(1)
end
Más respuestas (2)
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!