Create tiled layout with openfig

10 ビュー (過去 30 日間)
Vinayak
Vinayak 2022 年 8 月 15 日
回答済み: Adam Danz 2022 年 8 月 15 日
I wish to create a tiled layout of figures (say 1x3) and each figure is loaded using openfig.
Currently i am using the following code to implement the same:
h1 = openfig('fig1.fig','reuse'); % open figure
ax1 = gca;
h2 = openfig('fig2.fig','reuse'); % open figure
ax2 = gca;
h3 = openfig('fig3.fig','reuse'); % open figure
ax3 = gca;
figure;
tcl=tiledlayout(1,3);
ax1.Parent=tcl;
ax1.Layout.Tile=1;
ax2.Parent=tcl;
ax2.Layout.Tile=2;
ax3.Parent=tcl;
ax3.Layout.Tile=2;
But this code doesn't work. While it opens all the three figures, only one figure is show on the tiled layout (as shown below)
Can someone point my mistake or point to a more efficient way of implementing this?

回答 (1 件)

Adam Danz
Adam Danz 2022 年 8 月 15 日
  1. Call gca with the figure handle so you know it's accessing the axes within the figure you just opened (assuming there is only 1 axes within the opened figure). ax1 = gca(h1);
  2. Might by a typo but ax3 is assigned to tile #2 in your demo code.
If you continue to have the problem, show us what tcl.Children looks like after setting all of the parents.

カテゴリ

Find more on Printing and Saving in Help Center and File Exchange

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by