A way to plot legens for better performance?

4 次查看(过去 30 天)
Hello all, I am plotting data in a for() loop such that the data displays as a movie.
When I include plotting the legend, the plot times are considerable slower and the whole plot flashes blank each time the legend is plotted.
Is there a better way to do this. I am on a MacBook Pro and I think I have read elsewhere that mac version of MatLab features slow plots.
code - the legend plots are on subplot 3 and 4:
for i = 1:1:length(Y)
ti = time(i);
figure(18);
clf;
subplot(4,1,1);
plot(Y(1,i),solution_heigth(i),'o','MarkerSize',15);
hold on
plot(Y(1,i),-epsilon,'o','MarkerSize',15);
plot(Y(1,i),-epsilon,'x','MarkerSize',15);
text(Y(1,i),-epsilon*.95,['pos = ',num2str(Y(1,i)),' vel = ',...
num2str(Y(2,i))]);
plot(x,epsilon*cos(x-Ft(i)));
title([num2str(ti),' square wave, delta = 2.9, omega = pi']);
subplot(4,1,2)
plot(Y(1,1:i),Y(2,1:i));
hold on
title('phase space');
xlabel('x');
ylabel('dx/dt');
drawnow
subplot(4,1,3)
plot(time(1:i),Y(1,1:i),time(1:i),Y(2,1:i));
hold on
legend('position','velocity');
title('x')
subplot(4,1,4)
plot(time(1:i),orbitEnergy(1,1:i),time(1:i),orbitEnergy(2,1:i),...
time(1:i),orbitEnergy(3,1:i));
hold on
legend('kinetic','potential','total');
title('energy');
drawnow
end

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by