How can I optimize graphics update in animations?
Mostrar comentarios más antiguos
I have a plot with multiple subplots that I would like to create an auto-scrolling effect with. I first set up the figure:
xData = 0:0.001:60;
yData = sin(2*pi*xData);
xLimit = [0,5];
figure;
nAxes = 4; % Number of Axes
for i = 1:nAxes
Ax(i) = subplot(nAxes,1,i);
line('parent',Ax(i),'xdata',xData,'ydata',yData);
end
Then I iteratively update the 'x-axis' limits to achieve continuous panning of the plot.
step = 0.1;
while xLimit(2)<xData(end)
xLimit=xLimit+step;
for i=1:nAxes
xlim(Ax,xLimit)
end
pause(0.00001);
end
A small delay is added in each iteration using the 'pause' function. However, the graphics are not updating quickly enough to achieve smooth panning, and there is a small shake in the y-axis during the animation. A similar issue is reported here:
How do I achieve smoother panning of the plot?
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Animation en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!