【发布时间】:2021-05-19 03:47:32
【问题描述】:
我想使用 tiledlayout 在图中放置 5 个图,顶部为 2x2 的图,然后在底部的图跨两列。应该有两组轴标签:一组用于 2x2 绘图,另一组用于底部绘图。我的 MWE 是
x = linspace(-2,2,100);
y1 = sin(x);
y2 = cos(x);
y3 = sin(x).*cos(2*x);
y4 = sin(2*x).*cos(x);
y5 = y3 + y4;
figure('PaperUnits', 'inches', 'PaperSize', [4 6], 'PaperPosition', [0 0 4 6]);
t = tiledlayout(3,2,'TileSpacing','compact','Padding','compact');
nexttile; plot(x,y1); title('y_1');
nexttile; plot(x,y2); title('y_2');
nexttile; plot(x,y3); title('y_3');
nexttile; plot(x,y4); title('y_4');
xlabel(t,'time t_\alpha')
ylabel(t,'amplitude \alpha')
nexttile([1 2]); plot(x,y5); title('y_5');
xlabel('time t_\beta')
ylabel('amplitude \beta')
saveas(gcf,'myfig.jpg')
这给了我下图:
我希望 amplitude \alpha ylabel 和 time t_alpha xlabel 正确对齐 2x2 图(如我的红色注释所示)。有没有办法做到这一点?
我正在使用 MATLAB R2020a。请注意,tiledlayout 函数是在 R2019b 中引入的。
【问题讨论】:
-
也许你可以有一个嵌套的平铺布局,其中外部布局是 3x1,它的前两个位置由 2x2 平铺布局占据,最后一个位置是一个简单的绘图。我自己从未尝试过,但我认为它可以工作。另请提及您使用的 MATLAB 版本。
标签: matlab layout label alignment subplot