MATLAB Answers

2

Merging two figures

Asked by Mateusz on 24 Mar 2011
Latest activity Commented on by Walter Roberson
on 22 May 2018
I have two figures with different plots. I would like to merge them into one figure that contains both plots and with keeping the title of the figure and axis-labels (both figures have the same title and axis-labels). How can I do this in Matlab? I should also add that I am not interested in "do-by-hand" solution.

  0 Comments

Sign in to comment.

4 Answers

Answer by Loginatorist on 24 Mar 2011
 Accepted Answer

As an example,
figure(50)
plot(0:.01:1)
figure(60)
plot((0:.01:1).^2)
Now, do this:
L = findobj(50,'type','line');
copyobj(L,findobj(60,'type','axes'));
If you have different figure numbers, put them in place of the 50 and 60.

  4 Comments

Show 1 older comment
Excellent solution: works perfectly!! Thanks!
What if I have more than 2 figures to merge? Can you please tell me the code for this. Thank you.
You can use the kind of code I showed in https://www.mathworks.com/matlabcentral/answers/262265-duplicating-an-imshow-image-into-a-new-figure-without-using-imshow#comment_332459, just looping with f1 set to each source figure in turn.

Sign in to comment.


Answer by Ali Benmabrouk on 21 Jan 2015

Hello Friends, I have to merge two matlab figures (please take a look on the images below) in one figure in order to compare contours. How can do that??? Thank you so much.

  0 Comments

Sign in to comment.


Answer by Chunguo Wu on 23 Jan 2016

I'm also caring about this issue.

  0 Comments

Sign in to comment.