Merging multiple graphs in the same tiled layout
古いコメントを表示
Hi there, I'm attempting to merge a couple of graphs saved in the same tiled layout, but I'm not sure if that's possible to be honest. Here's what I mean:
%Meaningless values for graphs
a = 1:1:100
b = 5:5:500
c = 2:2:200
d = 400:-4:4
%Creating first figure w/ 2 graphs + saving
figure();
t = tiledlayout(1,2)
nexttile(t)
plot(a,b)
nexttile(t)
plot(b,a)
saveas(figure(1),'Fig1.fig')
%Creating second figure w/ 2 graphs + saving
figure()
t = tiledlayout(1,2)
nexttile(t)
plot(c,d)
nexttile(t)
plot(d,c)
saveas(figure(2),'Fig2.fig')
If I wanted to merge the four saved graphs into two in the same tiled layout (2x1) how might I go about doing that? Specifically, I'd like it where tile 1 is a,b & c,d on the same graph, and tile 2 is b,a & d,c on the same graph.
I've figured out that you can use the following code to make a combination just of the last graph in the layout, but this is somewhat unhelpful:
h1 = hgload('Fig1.fig')
h2 = hgload('Fig2.fig')
figure()
h(1) = subplot(1,1,1)
copyobj(allchild(get(h1,'CurrentAxes')),h(1));
copyobj(allchild(get(h2,'CurrentAxes')),h(1));
%This would show b,a & d,c on the same graph
I think I could reasonably do this without using any tiled layouts, saving each plot as a new figure, and then combining them in a tiled layout afterwards. Because of the amount of graphs I'm working with and how my figures are already saved as tiled, though, I'd like to see if anyone has any ideas on how to do it another way. Thank you!
1 件のコメント
Fifteen12
2023 年 9 月 21 日
採用された回答
その他の回答 (1 件)
the cyclist
2023 年 9 月 21 日
0 投票
If I understand what you mean, you just need to use the hold function (just after nexttile) to retain plots, rather than replacing them.
1 件のコメント
%Meaningless values for graphs
a = 1:1:100;
b = 5:5:500;
c = 2:2:200;
d = 400:-4:4;
%Creating first figure w/ 2 graphs + saving
figure();
t = tiledlayout(1,2);
nexttile(t)
plot(a,b)
hold on
plot(c,d)
nexttile(t)
plot(b,a)
hold on
plot(d,c)
カテゴリ
ヘルプ センター および File Exchange で Axes Appearance についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



