Merging two figures

543 次查看(过去 30 天)
Mateusz
Mateusz 2011-3-24
移动Dyuman Joshi 2023-11-23
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.
  1 个评论
Ali Benmabrouk
Ali Benmabrouk 2015-1-21
移动:Dyuman Joshi 2023-11-23
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.

请先登录,再进行评论。

采纳的回答

Matt Fig
Matt Fig 2011-3-24
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.
  10 个评论
Walter Roberson
Walter Roberson 2023-11-23
L = findobj(50,'type','line');
tells MATLAB to look for line objects starting from the object whose numeric handle is 50 .
In the time since @Matt Fig posted in 2011, MATLAB's graphics interface changed so that now the primary interface the user sees is "handles" instead of numbers for objects.
However, the numeric interface is still present and still works -- especially for the case where the number is a figure number.
Matt's example specifically used figure(50) which asks to create figure with numeric handle 50. That syntax is still in common use, especially with figure(1), figure(2), figure(3), and it is still valid. And if you have created a figure with an integer numeric handle in that way, then findobj() is happy to use the figure number as the first parameter, as long as that figure still exists.
Walter Roberson
Walter Roberson 2023-11-23
When you use findobj then the 'type' parameter is not case sensitive. The code Matt posted still works exactly as posted
figure(50)
plot(0:.01:1)
figure(60)
plot((0:.01:1).^2)
L = findobj(50,'type','line');
copyobj(L,findobj(60,'type','axes'));

请先登录,再进行评论。

更多回答(2 个)

Chunguo Wu
Chunguo Wu 2016-1-23
I'm also caring about this issue.

Walter Roberson
Walter Roberson 2016-1-23

类别

Help CenterFile Exchange 中查找有关 Graphics Object Programming 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by