Tiledlayoutの共有軸ラベルの位置について
조회 수: 23 (최근 30일)
이전 댓글 표시
Tiledlayoutで複数のグラフを作成し、各グラフの下側に各々のグラフのキャプションをつけています。最下列のグラフのキャプションとX軸に関する共有軸ラベルが重ならないように共有軸ラベルの位置を下げたいのですが方法ありますか。
댓글 수: 0
답변 (3개)
Atsushi Ueno
2023년 6월 27일
편집: Atsushi Ueno
2023년 6월 27일
状況を再現しました。tiledlayout の共有軸ラベル(Text objct)には 'Position' プロパティが存在せず、値を変更する事が出来ません。苦肉の策として、xlabel関数に複数行を表示させる機能があるので、2行表示させて1行目を空の文字列にするというのはどうでしょうか?
t = tiledlayout(2,2);
nexttile; plot(rand(1,20)); title('Long long Caption 1','Position',[10 -0.3 0]);
nexttile; plot(rand(1,20)); title('Long long Caption 2','Position',[10 -0.3 0]);
nexttile; plot(rand(1,20)); title('Long long Caption 3','Position',[10 -0.3 0]);
nexttile; plot(rand(1,20)); title('Long long Caption 4','Position',[10 -0.3 0]);
htx = xlabel(t,{'ぶつかってしまう!','Shared X Axis Label 2行目ならぶつからない!'});
tiledlayout の共有軸ラベル(Text objct)は隠しプロパティになっているようです。VerticalAlignmentというプロパティはありますが、Positionプロパティは見つかりませんでした。なぜでしょう?
mt = metaclass(htx); % 共有軸ラベルのTextオブジェクトに'Position'プロパティが無い
b = [{mt.PropertyList.Hidden}' {mt.PropertyList.Name}']
댓글 수: 0
Hiroshi Iwamura
2023년 6월 27일
Ueno さんが再現スクリプトを作ってくださっていますが、このように実際に試せるスクリプトを載せていただくと回答が付きやすいかと思います。
R2021a 以降であれば、空 legend を使う手もありますかね。
通常の各グラフの legend とも併用可能です。
t = tiledlayout(2,2);
nexttile; plot(rand(1,20)); title('Long long Caption 1','Position',[10 -0.3 0]);
nexttile; plot(rand(1,20)); title('Long long Caption 2','Position',[10 -0.3 0]);
nexttile; plot(rand(1,20)); title('Long long Caption 3','Position',[10 -0.3 0]);
nexttile; plot(rand(1,20)); title('Long long Caption 4','Position',[10 -0.3 0]);
% ここに空 legend を表示させて隙間を空ける
htx = xlabel(t,{'↑ Can you see this empty legend?'});
sg = sgtitle('Subplot Grid Title'); % なくても良い
% 空 legend
le = legend('');
le.Box = 'off';
le.Layout.Tile = 5;
le.FontSize = 7.2; % これで間隔調整可
le.Layout.Tile = "south";
댓글 수: 0
交感神経優位なあかべぇ
2023년 6월 28일
各グラフの下側に各々のグラフのキャプションのつけ方ですが、xlabelを使用してキャプションをつければ重ならないことに気づきました。
t = tiledlayout(2,2);
nexttile; plot(rand(1,20)); xlabel('Long long Caption 1');
nexttile; plot(rand(1,20)); xlabel('Long long Caption 2');
nexttile; plot(rand(1,20)); xlabel('Long long Caption 3');
nexttile; plot(rand(1,20)); xlabel('Long long Caption 4');
htx = xlabel(t,'ぶつかってしまわない!');
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 グラフィックス出力のターゲットの指定에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!