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

조회 수: 7 (최근 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