Create tiled layout with openfig

조회 수: 7 (최근 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.

카테고리

Help CenterFile Exchange에서 Printing and Saving에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by