Tiledlayou​tの共有軸ラベルの位​置について

20 visualizzazioni (ultimi 30 giorni)
matlab大学院生
matlab大学院生 il 27 Giu 2023
Tiledlayoutで複数のグラフを作成し、各グラフの下側に各々のグラフのキャプションをつけています。最下列のグラフのキャプションとX軸に関する共有軸ラベルが重ならないように共有軸ラベルの位置を下げたいのですが方法ありますか。

Risposte (3)

Atsushi Ueno
Atsushi Ueno il 27 Giu 2023
Modificato: Atsushi Ueno il 27 Giu 2023
状況を再現しました。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}']
b = 70×2 cell array
{[0]} {'String' } {[1]} {'StringMode' } {[1]} {'String_I' } {[0]} {'FontName' } {[1]} {'FontNameMode' } {[1]} {'FontName_I' } {[0]} {'FontAngle' } {[1]} {'FontAngleMode' } {[1]} {'FontAngle_I' } {[0]} {'FontWeight' } {[1]} {'FontWeightMode' } {[1]} {'FontWeight_I' } {[0]} {'Rotation' } {[1]} {'RotationMode' } {[1]} {'Rotation_I' } {[0]} {'HorizontalAlignment'}

Hiroshi Iwamura
Hiroshi Iwamura il 27 Giu 2023
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";

交感神経優位なあかべぇ
各グラフの下側に各々のグラフのキャプションのつけ方ですが、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,'ぶつかってしまわない!');

Prodotti

Community Treasure Hunt

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

Start Hunting!