one common y label for the subplots

171 次查看(过去 30 天)
I am trying to remove the y labels in the inner plots of my subplot figures by using straightforward codes which I couldn't, here's my code,
here I used position for ylabel which didn't work
is there a short way for this?
for r=1:10
subplot(2,13,r)
plot(u_lat_con(:,r)./Uund,yler_D2,'r');
xlabel('$\overline{u}/U_0$','interpreter','latex')
% ylabel('$y/D$','interpreter','latex')
ylabel('$y/D$','position',[-1 8],'interpreter','latex')
title(sprintf('x/D=%.2f',xler_c(r)./D))
xlim([-0.3 1.3]);
ylim([0 3.1133]);
end
% ylabel('$y/D$','POSITION',[-1 8],'interpreter','latex')
for r=1:13
subplot(2,13,r+13)
plot(u_lat_w(:,r)./Uund,yler_D1,'b',u_lat_w(:,r)./Uund,-yler_D1,'b');
xlabel('$\overline{u}/U_0$','position',[4 7],'interpreter','latex')
% ylabel('$y/D$','interpreter','latex')
title(sprintf('x/D=%.2f',xler1(r)./D))
xlim([-0.3 1.3])
ylim([-3.5 3.5])
end

采纳的回答

Cris LaPierre
Cris LaPierre 2021-10-14
编辑:Cris LaPierre 2021-10-14
If you use tiledlayout instead of subplot, you can add shared title and axis labels. See this example.
t = tiledlayout(2,2,'TileSpacing','Compact');
% Tile 1
nexttile
plot(rand(1,20))
% Tile 2
nexttile
plot(rand(1,20))
% Tile 3
nexttile
plot(rand(1,20))
% Tile 4
nexttile
plot(rand(1,20))
% Create shared title, xlabel and ylabel
title(t,'Size vs. Distance')
xlabel(t,'Distance (mm)')
ylabel(t,'Size (mm)')
  2 个评论
mehra
mehra 2021-10-14
I have some cases which doesn't have fixed m by n tiles,(2 rows with different columns in each row for example) so using subplot works better for me
Cris LaPierre
Cris LaPierre 2021-10-14
编辑:Cris LaPierre 2021-10-14
If you can do it with subplot, you should be able to do it with tiledlayout. You can jump to a specific tile using the syntax nexttile(7). For example, if your grid is 3x3, that command will take you to the bottom left tile.
This is equivalent to subplot(3,3,7).

请先登录,再进行评论。

更多回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by