Hello I have the following piece of code which plots my results:
h1 = figure;
h2 = figure;
for i = 1:5
figure(h1);
set(h1, 'Visible', 'off');
semilogy(0:iter_jac ,resvec_jac,'-*');
hold on;
figure(h2);
set(h2, 'Visible', 'off');
subplot(3,2,mesh);
plot(trace(:,2),trace_sol(:,1),trace(:,2),trace_sol(:,2),trace(:,2),trace_sol(:,3),trace(:,2),trace_sol(:,4));
xlabel('arc length');
ylabel('temperature');
legend('t = 2.5','t = 5.0','t = 7.5','t = 10');
title(sprintf('Mesh %d', mesh));
end
What this code is doing is basically plotting all the semilogy in one plot while the trace plots in on figure with different subplots. However the problem with this code is that it shows me the figure at every iteration of the for loop (so I see the new results being plotted) even if I set both figures invisible (they still appear for a second). How can I ONLY show the plots once the for loop has ended?
Calling
figure(h1)causes the figure to become visible.The best way around this is to explicitly use figure and axes handles to do all your work (instead of relying on the current figure/axes and changing those with
figureorsubplot). Functions that don't directly take a handle as input can take a name-value pair to set the property'parent'to a handle.[Note I've modified the code also to plot random data, this is just an illustration.]