Common xlabel and ylabel in a subplot of a subplot

42 次查看(过去 30 天)
Hello,
I would like to obtain a figure of (for example) 2 by 2 subplot, but with the last figure being another 2 by 2 subplot. If possible, I would like to use tiledlayout and nexttile, since I can edit the space between the figures.
My problem is that I would like to specify the xlabel and ylabel differently for the 3 bigger graphs and one general xlabel and ylabel for the smaller subplot (see the example in attachment and below).
In a basic example, I am almost able to achieve my goal, but I don't know how to set the last x and y labels for the smaller subplot.
x=sin(linspace(1,10)); % Set randomly for the example.
figure(1); t=tiledlayout(4,4,'TileSpacing','normal','Padding','compact');
nexttile([2,2])
plot(x); xlabel('x'); ylabel('y');
nexttile([2,2])
plot(x); xlabel('x'); ylabel('y');
nexttile([2,2])
plot(x); xlabel('x'); ylabel('y');
% How to set global xlabel and ylabel for the remaining 4 graphs?
ax1 = nexttile;
plot(x)
ax2 = nexttile;
plot(x)
ax3 = nexttile;
plot(x)
ax4 = nexttile;
plot(x)
Thank you in advance for your help!

采纳的回答

VBBV
VBBV 2021-5-22
x=sin(linspace(1,10)); % Set randomly for the example.
figure(1); t=tiledlayout(4,4,'TileSpacing','normal','Padding','compact');
nexttile([2,2])
plot(x); xlabel('x'); ylabel('y');
nexttile([2,2])
plot(x); xlabel('x'); ylabel('y');
nexttile([2,2])
plot(x); xlabel('x'); ylabel('y');
% How to set global xlabel and ylabel for the remaining 4 graphs?
ax1 = nexttile;
plot(x);
ax2 = nexttile;
plot(x);
ax3 = nexttile;
plot(x);
ax4 = nexttile;
plot(x);
xlabel([ax3 ax4],'x'); ylabel([ax1 ax3],'y')
do you mean this ?
  1 个评论
Gab D
Gab D 2021-5-23
Hi, thank you for your answer.
This could work, but I had in mind a common 'x' and 'y' for the small quadrant. Something like:
If nothing comes to mind, I will use your example!

请先登录,再进行评论。

更多回答(0 个)

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by