Transferring 4 already plotted figures into one with subplots

2 views (last 30 days)
Filip on 23 Mar 2018
Edited: per isakson on 20 May 2018
Hello community, I have currently from my code 4 printed figures: figure(101); figure(102), figure(103) & figure(104) (these also have subplots (2x2) of their own).
I would like to like to transfer them to be in one figure all together (a figure with 2x2 subplots), subplot(2,2,1) being figure(101), subplot(2,2,2) being figure(102), etc...
Any idea how I can do this in the best way possible?
%Example for the 4 figures:
colors = ['b','r','g','k'];
for j=1:4
for i = 1:4
subplot(2,2,i); hold on;
title(strcat('Figure: ',num2str(j),'-',num2str(i)))

Accepted Answer

per isakson
per isakson on 20 May 2018
Edited: per isakson on 20 May 2018
AFAIK: Matlab doesn't provide a specific tool to copy the content of separate figures to subplots of one figure. However, there might be something useful in The File Exchange (FEX).
Search the FEX: tag:subplot figure copy. The second hit is MontageFigures by Nick Sinclair, which I downloaded and tested:
Create four separate figures
colors = ['b','r','g','k'];
for jj=1:4
for ii = 1:4
title( sprintf( 'Figure: %d - %d', jj, ii ) )
Copy the content of the four figures to one new figure
montagefigures( [101,102,103,104],2,2)
Worked without any problems.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!