How to put existing figures in one figure together?
23 次查看(过去 30 天)
显示 更早的评论
I have two existing figures ('fig1.fig" and "fig2.fig"), and want to put in one figure together horizontally and vertically (creating 2 figures).
I tried to use "tiledlayout" spending some time, but failed.
Thank you very much,
openfig('fig1.fig')
openfig('fig2.fig')
0 个评论
采纳的回答
Voss
2024-4-14
% open the fig files in two new figures
f1 = openfig('fig1.fig','invisible');
f2 = openfig('fig2.fig','invisible');
% get the ConfusionMatrixChart in each figure
cmc1 = f1.Children;
cmc2 = f2.Children;
% alternate way to get the ConfusionMatrixChart in each figure
% cmc1 = findall(f1,'Type','ConfusionMatrixChart');
% cmc2 = findall(f2,'Type','ConfusionMatrixChart');
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,1,2);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% same thing, now with a vertical layout
% create a new figure with a tiledlayout
f = figure();
t = tiledlayout(f,2,1);
% copy the charts into the tiledlayout
h1 = copyobj(cmc1,t);
h2 = copyobj(cmc2,t);
% place them correctly
h1.Layout.Tile = 1;
h2.Layout.Tile = 2;
% delete the original figures
delete([f1 f2])
更多回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Printing and Saving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!