Common xlabel and ylabel in a subplot of a subplot

27 Ansichten (letzte 30 Tage)
Gab D
Gab D am 22 Mai 2021
Kommentiert: Gab D am 23 Mai 2021
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!

Akzeptierte Antwort

VBBV
VBBV am 22 Mai 2021
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 Kommentar
Gab D
Gab D am 23 Mai 2021
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!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by