#author("2023-04-05T17:24:13+09:00","default:Miyashita","Miyashita")
#author("2023-04-05T17:25:22+09:00","default:Miyashita","Miyashita")
* tiledlayout メモ [#r5d53b58]

** 基本 [#dc67de4f]
一つの Figure に複数パネルを配置するときは,ちょっと前から subplot ではなくて tiledlayout を使うのが標準になったらしい.~
基本的には
#codeprettify(lang-matlab){{
fig = figure;
tile = tiledlayout(3,2); % 3行2列

%% --- 1つめの図 ---
ax(1) = nexttile;
% 何かプロット



%% --- 2つめの図 ---
ax(2) = nexttile;
% 何かプロット

% 以降同じ ...

}}
のようにやる.~
~
~

**タイルの配置の指定 [#n1ca65f3]
#codeprettify(lang-matlab){{
ax = nexttile;
}}
のところは, 引数がなければ subplot と同じように左上から始まり,次は1行2列,1行3列...のように進んでいく.~
凡例用にとっておくなど,特定のタイルを飛ばして次のプロットで配置されるタイルの場所を指定したい時は
#codeprettify(lang-matlab){{
ax = nexttile(5);
}}
とタイル番号を明示すればOK.~
~
~

**余白,タイル間の空白調整 [#wce6fb7b]
subplot と比べてこれが断然楽になった.論文のための図作成も簡単.~
#codeprettify(lang-matlab){{
tile = tiledlayout(3,2);
}}
などと tile という変数をつくった場合には,全部プロットしたあとに
#codeprettify(lang-matlab){{
tile.TileSpacing = 'tight';
tile.Padding = 'tight';
}}
とする. tight にしたらキツキツで, 'compact' にするとちょっと余裕がある.~
~
~

***参考 MathWorks公式 [#l7650f43]
-[[tiledlayout>https://jp.mathworks.com/help/matlab/ref/tiledlayout.html]]

Front page   Edit Diff Attach Copy Rename Reload   New List of pages Search Recent changes   Help   RSS of recent changes