Set one common Xaxis for a sublot with rows = 1 and columns = 2

조회 수: 11 (최근 30일)
Ron Nativ
Ron Nativ 2022년 7월 31일
댓글: Ron Nativ 2022년 8월 1일
Hello all,
I am having difficulties setting one shared\common Xaxis label for subplot with one row and two columns [e.g., subplot(1,2,1)].
Although there are a few realted answers in the forum, none seems to work for me.
I would appreciate your help!
Thanks, Ron
  댓글 수: 1
dpb
dpb 2022년 7월 31일
'Splain what you're after more fully -- neither subplot nor tiledlayout support sharing axes although the latter has shared title/legends. One would have to overlay the area with additional axes or draw a small-height one to add additional.
Show what you tried and what didn't please...there may be submissions on FEX but I've not looked.

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

채택된 답변

dpb
dpb 2022년 8월 1일
편집: dpb 2022년 8월 1일
I overlooked the labels in the original Q? body and thought was to have a combination axis itself of some sort based on title -- hence the response asking for clarification.
For the actual Q? as @the cyclist mentions above, use tiledlayout instead of subplot() which has been deprecated and won't be updated further it would appear.
From the doc examples for tiledlayout --
?Display a shared title and axis labels by passing t to the title, xlabel, and ylabel functions."
t = tiledlayout(2,2,'TileSpacing','Compact');
...
title(t,'Size vs. Distance')
xlabel(t,'Distance (mm)')
ylabel(t,'Size (mm)'
  댓글 수: 1
Ron Nativ
Ron Nativ 2022년 8월 1일
Thanks! I find the code working utilizing tiledlayout(1,2,...), as follows (e.g.,):
t = tiledlayout(1,2,'TileSpacing','Compact');
nexttile
plot(1:10,1:10)
nexttile
plot(1:10,10:19)
title(t,'Size vs. Distance')
xlabel(t,'Distance (mm)')
ylabel(t,'Size (mm)')
Ron

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

추가 답변 (1개)

the cyclist
the cyclist 2022년 7월 31일
편집: the cyclist 2022년 7월 31일
You may find the linkaxes command useful. You can also share properties (e.g. titles, xlabels) in a tiledlayout.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by