MATLAB Answers

Common Y label for multiple subplots in MATLAB!!!

531 views (last 30 days)
kader
kader on 22 Dec 2016
Answered: He Zhu Zhu on 15 Nov 2019
Can anyone please help, how to put common y label for multiple subplots in MATLAB figures?

  0 Comments

Sign in to comment.

Accepted Answer

KSSV
KSSV on 22 Dec 2016
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');

  2 Comments

Vasishta Kanthi
Vasishta Kanthi on 3 May 2019
A very elegant solution!!! Awesome!!! Highly Recommended!!

Sign in to comment.

More Answers (1)

He Zhu Zhu
He Zhu Zhu on 15 Nov 2019
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');

  0 Comments

Sign in to comment.

Tags