one common y label for the subplots
63 次查看(过去 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
0 个评论
采纳的回答
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 个评论
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 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!