MATLAB Answers


how to change the font size in a plot (only for the axes numbers)?

Asked by Kobi
on 22 Aug 2014
Latest activity Commented on by Adam
on 22 Aug 2014

as you can see in the attached image i need to change only the size of the numbers not the title or the colorbar how can i do this? thank you



2 Answers

Answer by Ben11
on 22 Aug 2014

Use the 'FontSize' property of the current axes:



on 22 Aug 2014

Yep for me it works also; i.e. it does the same as @Star Strider. Please see my comment below. OF course I used dummy values for the ticks and titles font size, but you can resize the title after changing the ticks if you like.

on 22 Aug 2014

Example code:

x = 1:6*pi;
title('This is sin(x) vs x');

outputs this:

What you can do if you want to change the size of the title is assigning it a handle and modify its "FontSize" property directly:

hTitle = title('This is sin(x) vs x');
on 22 Aug 2014

Be sure to add the title before setting font size. If you change font size then add the title it will be in the font size you just set. Though you can change it again afterwards.

Answer by Adam
on 22 Aug 2014

If you search for 'tick labels' or something similar, in the file exchange there are numerous options that replace the tick labels locked into the axes font size with text objects that can be manipulated independently.

I can't vouch for any particular one as I have never used any of them though.


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!