フィルターのクリア

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

6 ビュー (過去 30 日間)
Douwe Horsthuis
Douwe Horsthuis 2022 年 10 月 24 日
編集済み: Nirupama Nagarathinam 2022 年 11 月 2 日
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 Center および File ExchangeAxis Labels についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by