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

10 次查看(过去 30 天)
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?

采纳的回答

Oliver Woodford
Oliver Woodford 2011-4-19
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

更多回答(1 个)

Jan
Jan 2011-4-19
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.

类别

Help CenterFile Exchange 中查找有关 Printing and Saving 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by