Common Y label for multiple subplots in MATLAB!!!

84 visualizaciones (últimos 30 días)
kader
kader el 22 de Dic. de 2016
Comentada: Victoria Dutch el 30 de Nov. de 2020
Can anyone please help, how to put common y label for multiple subplots in MATLAB figures?

Respuesta aceptada

KSSV
KSSV el 22 de Dic. de 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');
  4 comentarios
Eric Sargent
Eric Sargent el 22 de Oct. de 2020
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 el 30 de Nov. de 2020
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?

Iniciar sesión para comentar.

Más respuestas (1)

He Zhu Zhu
He Zhu Zhu el 15 de Nov. de 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');

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by