Merge saved figures into one figure in the same plot

조회 수: 17 (최근 30일)
masterm667
masterm667 2021년 3월 6일
답변: masterm667 2021년 3월 6일
I was unable to replicate the code from user "meghannmarie" in the forum and my figures would not merge. It would produce a blank plot. I am new to this technique of combining figures on Matlab (I'm generally used to merging figures using "hold on" and then "plot," but I am unable to use this for my code) and any advice or additional information is much appreciated. I think the issue could be due to the axes being different, but I am not too sure because I am trying to understand what "children" and "parent" are. Thank you for your time.
fig = figure();
ax = axes(fig);
hold on
h1 = openfig('T_900K.fig','reuse');
h2 = openfig('T_1000K.fig','reuse');
h3 = openfig('T_1100K.fig','reuse');
h4 = openfig('T_1200K.fig','reuse');
h5 = openfig('T_1300K.fig','reuse');
h6 = openfig('T_1400K.fig','reuse');
copyobj(h1.Children.Children,ax);
copyobj(h2.Children.Children,ax);
copyobj(h3.Children.Children,ax);
copyobj(h4.Children.Children,ax);
copyobj(h5.Children.Children,ax);
copyobj(h6.Children.Children,ax);
close(h1);
close(h2);
close(h3);
close(h4);
close(h5);
close(h6);

채택된 답변

masterm667
masterm667 2021년 3월 6일
I managed to find the answer to my own question. If anyone was curious, the following video was very helpful: https://www.youtube.com/watch?v=x4TXEaAYfMw
My code is as follows:
h1=hgload('T_900K.fig');
h2=hgload('T_1000K.fig');
h3=hgload('T_1100K.fig');
h4=hgload('T_1200K.fig');
h5=hgload('T_1300K.fig');
h6=hgload('T_1400K.fig');
figure
h(1)=subplot(1,1,1);
copyobj(allchild(get(h1,'CurrentAxes')),h(1));
copyobj(allchild(get(h2,'CurrentAxes')),h(1));
copyobj(allchild(get(h3,'CurrentAxes')),h(1));
copyobj(allchild(get(h4,'CurrentAxes')),h(1));
copyobj(allchild(get(h5,'CurrentAxes')),h(1));
copyobj(allchild(get(h6,'CurrentAxes')),h(1));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating, Deleting, and Querying Graphics Objects에 대해 자세히 알아보기

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by