How can I label my graphs as (a), (b), (c) etc in subplot matlab?
Show older comments
I want to describe the graphs in figure caption by referencing them as (a), (b) (c) etc
1 Comment
Matt J
on 18 May 2023
Easiest just to add them in Powerpoint.
Accepted Answer
More Answers (4)
Sterling Baird
on 21 Oct 2020
Edited: Sterling Baird
on 21 Oct 2020
Personally, I've liked using:
nIDs = 4;
alphabet = ('a':'z').';
chars = num2cell(alphabet(1:nIDs));
chars = chars.';
charlbl = strcat('(',chars,')'); % {'(a)','(b)','(c)','(d)'}
text(0.025,0.95,charlbl{1},'Units','normalized','FontSize',12)
This works fine for me for tiled layouts, and does a decent job for scientific figures.

4 Comments
Sreeraj T
on 21 Oct 2020
This is pretty nice. One can also change
'a':'z'
to
'1':'9'
and see the difference!
Wiqas Ahmad
on 13 Apr 2022
I'm using the same command for labeling my subplots, however I want to place the labels (a),(b),... outside of the axes subplot. How can I do it?
Image Analyst
on 13 Apr 2022
@Wiqas Ahmad Try using text() or put it into the title or axes labels using sprintf() and title() or xlabel() or ylabel().
Sanita Dhaubanjar
on 2 May 2023
You can make the label generation shorter using:
charlbl = compose("(%s)",('a':'z').');
madhan ravi
on 13 Dec 2018
Edited: madhan ravi
on 13 Dec 2018
Use legend()
legend('(a)','(b)','(c)')
1 Comment
Shikhar Saxena
on 13 Dec 2018
Alex Ryabov
on 7 Jul 2021
Edited: Alex Ryabov
on 7 Jul 2021
I hope this function will help
fg = figure(1);
clf
subplot(2, 2, 1)
subplot(2, 2, 2)
subplot(2, 1, 2)
legend
colorbar
AddLetters2Plots(fg, 'HShift', 0, 'VShift', 0, 'Direction', 'TopDown')

Dion Wilde
on 17 May 2023
Edited: Dion Wilde
on 18 May 2023
Personally i found my optimum with the following solution:
ax=gca;
% read out the position of the axis in the unit "characters"
set(ax,'Units','characters'); a=get(ax,'Position');
% this determines the type of the plot
if isequal(get(ax,'View'),[0 90]) % this is used for 2D plots
str_place=2;
else % this is used for 3D plots, in this case also all other plots
str_place=-2;
end
% this sets an 'a)' right at the top left of the axes
text(ax,0,a(end)+str_place,'a)','Units','characters')
I specifically used the units "characters" here, because it consistently sets the character above the axes indepently of the actual size of the axis. The latter is difficult if not impossible to do with "units", "normalized".
2 Comments
Sreeraj T
on 18 May 2023
What does "end" in the last line indicates? It ends what?
Dion Wilde
on 18 May 2023
my bad, i copy pasted it from my own code. I deleted the "end".
Categories
Find more on Graphics Object Properties 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!
