How to add a title for any subplot in addition to a subplot title?
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Armando MAROZZI
am 9 Aug. 2021
Kommentiert: Armando MAROZZI
am 9 Aug. 2021
Let's assume I want to plot a few series using subplot:
x = randn(20,12);
for i = 1:size(x,2)
subplot(3,4,i)
plot(x(:,i),'-k')
title('Title')
end
Now, I want to add a title for each of the three rows. I only manage to display one for the first row as follows:
sgtitle('Title row I')
for i = 1:size(x,2)
subplot(3,4,i)
plot(x(:,i),'-k')
title('Title')
end
How can I add an "sgtitle" for every new row?
Thanks!
0 Kommentare
Akzeptierte Antwort
Dave B
am 9 Aug. 2021
You can do this sort of thing with tiledlayout instead of subplot, taking advantage of nested layouts:
t = tiledlayout(3,1); % tiledlayout to hold other tiledlayouts
for i = 1:3
tt = tiledlayout(t,1,4);
tt.Layout.Tile=i;
for ii = 1:4
nexttile(tt)
plot(rand(10,1))
title('axes title')
end
title(tt,sprintf('Row %d Title', i),'FontSize',11)
end
title(t,'Master Title')
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!