필터 지우기
필터 지우기

Setting the size of a tile when loading pre-created matlab figures

조회 수: 6 (최근 30일)
Is it possible to set the size of a tile if you are working with pre-created matlab figures that you need to load?
As answered here, one can load the figures and add them to a new subplot. And as usual you can set the size of the subplot for example like this: s6 = subplot(3,3,[7:9]);
Is this also possible for tiles?
The suggested code for working with tiles from the previously mentioned question:
openfig('fig1.fig');
ax1=gca;
openfig('fig2.fig')
ax2=gca;
figure;
tcl=tiledlayout(1,2);
ax1.Parent=tcl;
ax1.Layout.Tile=1;
ax2.Parent=tcl;
ax2.Layout.Tile=2;
Since this does not use the nexttile function, I wouldn't know where to say how big the tiles should be.
Thank you for your time!

채택된 답변

Nirupama Nagarathinam
Nirupama Nagarathinam 2022년 10월 28일
편집: Nirupama Nagarathinam 2022년 11월 2일
Yes, it is possible to set the size of tile with "TileSpan" property like that of "subplot" without using "nexttile".
Refer to this modified code:
openfig('fig1.fig');
ax1=gca;
openfig('fig2.fig')
ax2=gca;
figure;
tcl=tiledlayout(2,2); % 2 by 2 tile layout, so 4 tiles available
ax1.Parent=tcl;
ax1.Layout.Tile=1; % placing fig1 in the first tile
% For the figure to span multiple tiles, specify the "TileSpan" property as a two-element vector.
% The first element specifies the number of rows and the second element specifies the number of columns the figure should span.
ax1.Layout.TileSpan=[1 2]; % This code spans fig1 across one row and two columns of tiles starting from tile 1. So it occupies tiles 1 and 2.
ax2.Parent=tcl;
ax2.Layout.Tile=3; % placing fig2 in the third tile
ax2.Layout.TileSpan=[1 2]; % This code spans fig2 across one row and two columns of tiles starting from tile 3. So it occupies tiles 3 and 4.
I have verified the above code in R2019b MATLAB. Though "TileSpan" property was incorporated in the R2019b MATLAB release, it was not mentioned in the R2019b documentation. Hence, refer to this latest documentation link for more details.
  댓글 수: 1
Douwe Horsthuis
Douwe Horsthuis 2022년 10월 28일
This works perfect. With the added bonus that legends are also transfered into the final figure. Which wasn't the case when I would use subplot.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

제품


릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by