How can I render and export many figures without the figures grabbing the window focus all the time?

28 views (last 30 days)
I am rendering many figures in a sequence, and exporting them as images (I use export_fig, but could equally use saveas or print). While the program is running I'd like to be able to do other things on my computer, but the figure window keeps stealing the window focus, making this very difficult.
Any solutions?

Accepted Answer

Oliver Woodford
Oliver Woodford on 19 Apr 2011
The easiest option is to use the same figure window for each figure, and clear it before each new rendering. If you need to reset the current figure, use:
set(0, 'CurrentFigure', fh);
instead of:
figure(fh);
to avoid the focus being stolen.
In summary:
fh = figure;
for a = 1:num_figs
% Generate the data for rendering here
A = rand(10, 3);
% Select the figure and clear it
set(0, 'CurrentFigure', fh);
clf reset;
% Rendering code here
plot(A);
% Figure exporting code here (don't use saveas or getframe)
print(fh, '-depsc', sprintf('test%3.3d.eps', a));
end

More Answers (1)

Jan
Jan on 19 Apr 2011
I do not get this behaviour with PRINT:
Fig1H = figure;
plot(1:10);
Fig2H = figure;
pause(2);
text(0.5, 0.5, 'Printing now');
drawnow;
print(Fig1H, '-depsc', fullfile(tempdir, 'test.eps'));
This does not activate Figure 1 under Matlab 2009a.

Categories

Find more on Printing and Saving in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!