Create tiled layout with openfig

9 views (last 30 days)
Vinayak
Vinayak on 15 Aug 2022
Answered: Adam Danz on 15 Aug 2022
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?

Answers (1)

Adam Danz
Adam Danz on 15 Aug 2022
  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.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!