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

12 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

Oliver Woodford
Oliver Woodford il 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

Più risposte (1)

Jan
Jan il 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.

Categorie

Scopri di più su Printing and Saving in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by