How to add a title for any subplot in addition to a subplot title?
8 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Dave B
2021-8-9
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')
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!