Common Y label for multiple subplots in MATLAB!!!

조회 수: 25 (최근 30일)
kader
kader 2016년 12월 22일
댓글: Victoria Dutch 2020년 11월 30일
Can anyone please help, how to put common y label for multiple subplots in MATLAB figures?

채택된 답변

KSSV
KSSV 2016년 12월 22일
figure;
h1=subplot(2,1,1);
h2=subplot(2,1,2);
p1=get(h1,'position');
p2=get(h2,'position');
height=p1(2)+p1(4)-p2(2);
h3=axes('position',[p2(1) p2(2) p2(3) height],'visible','off');
h_label=ylabel('test','visible','on');
  댓글 수: 4
Eric Sargent
Eric Sargent 2020년 10월 22일
As of R2019b you can used tiledlayout and add shared labels.
t = tiledlayout(2,2);
t.YLabel.String = 'My y-Axis Label';
Alternatively, pass the TiledChartLayout object to the ylabel function.
t = tiledlayout(2,2);
ylabel(t,'My y-Axis Label');
Victoria Dutch
Victoria Dutch 2020년 11월 30일
How would you make this work when using yyaxis? Both my y-labels are showing up on top of each other on the left, and I need one on the left and one on the right, but both vertically centered?

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

추가 답변 (1개)

He Zhu Zhu
He Zhu Zhu 2019년 11월 15일
If you used common Y label for multiple subplots, you might need to link the axes. The simplest way to do this is linkaxes function. Linked axes will behave synchronously when using pan or zoom tools.
ax1 = subplot(1, 2, 1);
ax2 = subplot(1, 2, 2);
linkaxes([ax1, ax2], 'y');

카테고리

Help CenterFile Exchange에서 Axes Appearance에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by