How to align textbox in matlab plot?

7 次查看(过去 30 天)
I have used tiledlayout to plot 6 figures in 3 cloumns and 2 rows. I have to use the textbox to number them from (a)-(f). Legend is lready been used as each plot has multiple graphs. Is it possible that I can put all the six textbox in the same position of the respecitve graph? I just want to make the figures easily readable.

采纳的回答

Voss
Voss 2024-3-19
编辑:Voss 2024-3-19
"Is it possible that I can put all the six textbox in the same position of the respecitve graph?"
Yes. Here's an example that places each text object at Position [0,1] in 'normalized' Units, which is the upper-left corner of the axes.
f = figure();
tl = tiledlayout(f,2,3);
names = "("+string(char('a'+(0:5).'))+")";
for ii = 1:6
nexttile(tl)
plot(randi([1,100])*rand(1,10))
text(0,1,names(ii), ...
'Units','normalized', ...
'VerticalAlignment','bottom', ...
'FontWeight','bold')
end
  1 个评论
Voss
Voss 2024-3-19
编辑:Voss 2024-3-19
You could use the title function to do the same thing (if you don't already have any titles), since title creates a text object.
f = figure();
tl = tiledlayout(f,2,3);
names = "("+string(char('a'+(0:5).'))+")";
for ii = 1:6
nexttile(tl)
plot(randi([1,100])*rand(1,10))
title(names(ii), ...
'Units','normalized', ...
'Position',[0 1], ...
'VerticalAlignment','bottom', ...
'HorizontalAlignment','left', ...
'FontWeight','bold')
end

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息

产品


版本

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by