How to add animatedline to formatted figure?
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
arianne ford
el 24 de Mzo. de 2021
Comentada: arianne ford
el 25 de Mzo. de 2021
Hi all,
I am trying to get an animated line to plot on an already formatted figure. Simplified code below:
figure();
xlabel ('x');
ylabel ('y');
axis ([0 10000 0 10]);
grid on;
title('my plot', 12);
myline1 = animatedline('Color', 'r');
a = 0;
b = 1000000;
while a<b
x1 = somevalue;
y1 = someothervalue;
set(0, 'CurrentFigure', 1);
addpoints(myline1, x1, y1)
drawnow
a = a+1;
end
However what I'm getting from this is a nicely formatted figure with the axis titles and the range of values but empty of data points, and the animatedline plotting in another figure window. How can I get the animated line to plot onto the existing figure with the required formatting?
The code outputs the correct values for x1 and y1, it's just the plot that I'm struggling with.
Apologies if I'm missing the obvious, this is the first time I've used Matlab in nearly 20 years. Trying to relearn!
Would appreciate any advice.
0 comentarios
Respuesta aceptada
Les Beckham
el 25 de Mzo. de 2021
From what you have posted, you have explicitly requested a new figure with the line:
figure();
This will create a new figure and subsequent plotting commands will put their output into this new figure, not any previously created figure.
Consider removing the figure() line and replacing by
hold on
It also sounds like you are having issues with the "nicely formatted figure" since you say it is "empty of data points".
If you wish to get help with that you will need to post the code that you are using to create that as well.
Más respuestas (0)
Ver también
Categorías
Más información sobre Animation 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!