Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

labelling subplots automatically

Tags:

matlab

I have 4 subplots in a figure and want to label them a, b, c, and d. I would like for the letters to be placed automatically in the top left hand corner of each subplot. I know that I can add text manually, but is there a more efficent way to do this?

like image 230
Brian Avatar asked Oct 29 '25 17:10

Brian


1 Answers

You can put something along these lines into a script:

subplot(2,2,1)
text(0.02,0.98,'a','Units', 'Normalized', 'VerticalAlignment', 'Top')
subplot(2,2,2)
text(0.02,0.98,'b','Units', 'Normalized', 'VerticalAlignment', 'Top')
subplot(2,2,3)
text(0.02,0.98,'c','Units', 'Normalized', 'VerticalAlignment', 'Top')
subplot(2,2,4)
text(0.02,0.98,'d','Units', 'Normalized', 'VerticalAlignment', 'Top')

Note that I'm assuming your subplots are arranged in a 2x2 grid and that they are all 2D plots. If these assumptions do not hold, modify the first two arguments of subplot and/or add a z coordinate to text.

like image 151
Nick Atoms Avatar answered Oct 31 '25 12:10

Nick Atoms