one common y label for the subplots
조회 수: 65 (최근 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!