How can I label my graphs as (a), (b), (c) etc in subplot matlab?

525 views (last 30 days)
I want to describe the graphs in figure caption by referencing them as (a), (b) (c) etc

Accepted Answer

Image Analyst
Image Analyst on 13 Dec 2018
Use subplot() and title().
% Plot (a) plot.
subplot(3, 1, 1);
plot(1:10, 'r-');
title('(a)', 'FontSize', 15);
% Plot (b) plot.
subplot(3, 1, 2);
plot(10*sin(0:.1:10), 'b-', 'LineWidth', 2);
grid on;
title('(b)', 'FontSize', 15);
% Plot (a) plot.
subplot(3, 1, 3);
plot(cos(1:10), 'k*', 'MarkerSize', 15, 'LineWidth', 2);
grid on;
title('(c)', 'FontSize', 15);
0000 Screenshot.png
Or you could use xlabel() if you want to put the letters under the x axis, or text() if you want to place them wherever you want.
Sterling Baird
Sterling Baird on 19 Oct 2020
I think Image Analyst's solution may need a bit more to get left alignment.

Sign in to comment.

More Answers (3)

Sterling Baird
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)'}
This works fine for me for tiled layouts, and does a decent job for scientific figures.
  1 Comment
sreeraj t
sreeraj t on 21 Oct 2020
This is pretty nice. One can also change
and see the difference!

Sign in to comment.

madhan ravi
madhan ravi on 13 Dec 2018
Edited: madhan ravi on 13 Dec 2018
Use legend()
  1 Comment
Shikhar Saxena
Shikhar Saxena on 13 Dec 2018
No, legend is different. I want to label each graph as a,b,c etc. Like see in figure below generated through subplot function matlab, I want to label three graphs as a, b and c. try.png

Sign in to comment.

Alex Ryabov
Alex Ryabov on 7 Jul 2021
Edited: Alex Ryabov on 7 Jul 2021
I hope this function will help
fg = figure(1);
subplot(2, 2, 1)
subplot(2, 2, 2)
subplot(2, 1, 2)
AddLetters2Plots(fg, 'HShift', 0, 'VShift', 0, 'Direction', 'TopDown')





Community Treasure Hunt

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

Start Hunting!