combining multiple open figures into 1

Hi, I have 12 open figures. I want to create a new figure containing subplots(3,4,x), x being the 12 figures. How can I do this?
My aim has been to try using findobj to get the figure handles and doing copyobj but I can't figure it out...
Any help will be appreciated. Thanks!

 Accepted Answer

See the example given in the accepted answer to this question.
%
%
%
%
EDIT After clarifying comments.
Here is another example with subplots. I didn't do 80, but I think you can adapt this to your needs. As before, there is a pause in there so that you can first look at the four figures before they are destroyed. Notice the color order is preserved. Once you are done looking, simply hit return at the command line to see the new figure.
C = {'r';'b';'k';'g'}; % Colors for plots
% Make some figures...
figure
for ii = 1:4
subplot(2,2,ii)
plot((1:10).^(1+(ii-1)/4),C{ii});
end
figure
for ii = 1:4
subplot(2,2,ii)
plot((1:10).^(2+(ii-1)/4),C{ii});
end
figure
for ii = 1:4
subplot(2,2,ii)
plot((1:10).^(3+(ii-1)/4),C{ii});
end
figure
for ii = 1:4
subplot(2,2,ii)
plot((1:10).^(4+(ii-1)/4),C{ii});
end
pause % Wait for user to hit return...
fh = figure;
for ii = 1:16
subplot(4,4,ii)
P{ii} = get(gca,'pos');
end
clf(fh)
set(fh,'handlevis','callback')
% SUBPLOT goes by rows, so we must rearrainge...
POS = [1 2 5 6;3 4 7 8;9 10 13 14;11 12 15 16];
F = flipud(findobj('type','figure'));
for jj = 1:length(F)
ax = flipud(findobj(F(jj),'type','axes'));
for ii = 1:length(ax)
set(ax(ii),'parent',fh,'pos',P{POS(jj,ii)})
pause(.2)
end
close(F(jj))
end

5 Comments

Yes, if you look at the asker's question you'll see that he didn't want to lose his figures which took a long time to make. That is why I suggested he save them first. You can do it either way, just be sure you understand what the code in the example is doing. Feel free to email me if you want more help.
Thanks for the help Matt. That seemed to work for most of it. The problem I have is that figures 1~4 are subplots themselves (rasters to be exact) and doing what you suggested results only one of the lines to show up instead of the entire figure. Is there a way I can fix this?
You mean that figures 1-4 have subplots? A figure is the actual window where the axes are drawn. A subplot is really an axes object. So with this terminology in mind please describe exactly what you have. Like:
I have 3 figures, each with 4 subplots and I want to take all of the subplots from all 3 figures and put them into 1 separate figure.
Then we will see what can be done.
Yes, sorry for the confusion. For figures 1~4, each figure has 80 subplots. I want to take all subplots from figure 1, put them into a new figure on the upper left side. For figure 2, I want to take all subplots and put them adjacently to those of figure 1 in the new figure. Hope that clarified what i'm trying to do. Once again, thanks for your help!
It worked! Thank you so much!

Sign in to comment.

More Answers (0)

Asked:

S
S
on 24 May 2011

Community Treasure Hunt

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

Start Hunting!