How to prevent plots from resizing in making GIFs
I am trying to implement two plots changing side-by-side as a GIF, but I’m noticing that the plots keep changing size and move around which makes the animation a bit jarring. Does anyone know what I could do to fix this?
Here is the code I’m using to generate the GIFs (the entire code is rather long so this is just the portion dedicated to plotting):
I initialize (outside the for loop) with
figure
subplot(1,2,1)
hold on
p1 = plot(dom_plot,u_sol, ‘r’);
xlim([-pi pi])
axis square
drawnow
subplot(1,2,2)
hold on
plot(k, norm(uv), ‘b.’, ‘markersize’, 10)
axis square
drawnow
And then within the for loop I update it as:
subplot(1,2,1)
p1 = plot(dom_plot, real(u_sol), ‘r’);
cla(p1)
axis([-pi, pi, -max_plot, max_plot])
drawnow
axis square
subplot(1,2,2)
plot(uv_0(end), norm(uv_0(1:end-1)), ‘b.’, ‘markersize’, 10)
drawnow
axis square
exportgraphics(gcf,’w_4_2_animation.gif’,’Append’,true);
Below is an example of what one of these animations looks like. Any help would be much appreciated; thank you!I am trying to implement two plots changing side-by-side as a GIF, but I’m noticing that the plots keep changing size and move around which makes the animation a bit jarring. Does anyone know what I could do to fix this?
Here is the code I’m using to generate the GIFs (the entire code is rather long so this is just the portion dedicated to plotting):
I initialize (outside the for loop) with
figure
subplot(1,2,1)
hold on
p1 = plot(dom_plot,u_sol, ‘r’);
xlim([-pi pi])
axis square
drawnow
subplot(1,2,2)
hold on
plot(k, norm(uv), ‘b.’, ‘markersize’, 10)
axis square
drawnow
And then within the for loop I update it as:
subplot(1,2,1)
p1 = plot(dom_plot, real(u_sol), ‘r’);
cla(p1)
axis([-pi, pi, -max_plot, max_plot])
drawnow
axis square
subplot(1,2,2)
plot(uv_0(end), norm(uv_0(1:end-1)), ‘b.’, ‘markersize’, 10)
drawnow
axis square
exportgraphics(gcf,’w_4_2_animation.gif’,’Append’,true);
Below is an example of what one of these animations looks like. Any help would be much appreciated; thank you! I am trying to implement two plots changing side-by-side as a GIF, but I’m noticing that the plots keep changing size and move around which makes the animation a bit jarring. Does anyone know what I could do to fix this?
Here is the code I’m using to generate the GIFs (the entire code is rather long so this is just the portion dedicated to plotting):
I initialize (outside the for loop) with
figure
subplot(1,2,1)
hold on
p1 = plot(dom_plot,u_sol, ‘r’);
xlim([-pi pi])
axis square
drawnow
subplot(1,2,2)
hold on
plot(k, norm(uv), ‘b.’, ‘markersize’, 10)
axis square
drawnow
And then within the for loop I update it as:
subplot(1,2,1)
p1 = plot(dom_plot, real(u_sol), ‘r’);
cla(p1)
axis([-pi, pi, -max_plot, max_plot])
drawnow
axis square
subplot(1,2,2)
plot(uv_0(end), norm(uv_0(1:end-1)), ‘b.’, ‘markersize’, 10)
drawnow
axis square
exportgraphics(gcf,’w_4_2_animation.gif’,’Append’,true);
Below is an example of what one of these animations looks like. Any help would be much appreciated; thank you! gifs, animation, gif, animations, figures, 3d plots MATLAB Answers — New Questions