How to align textbox in matlab plot?

22 views (last 30 days)
ANANTA BIJOY BHADRA
ANANTA BIJOY BHADRA on 19 Mar 2024
Edited: Voss on 19 Mar 2024
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.

Accepted Answer

Voss
Voss on 19 Mar 2024
Edited: Voss on 19 Mar 2024
"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 Comment
Voss
Voss on 19 Mar 2024
Edited: Voss on 19 Mar 2024
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

Sign in to comment.

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

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

Start Hunting!