How to add a title for any subplot in addition to a subplot title?
9 views (last 30 days)
Show older comments
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 Comments
Accepted Answer
Dave B
on 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')
More Answers (0)
See Also
Categories
Find more on Title in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!