How to add a title for any subplot in addition to a subplot title?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Armando MAROZZI
le 9 Août 2021
Commenté : Armando MAROZZI
le 9 Août 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 commentaires
Réponse acceptée
Dave B
le 9 Août 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')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!