How can I change the font size of the current axis?
3.540 views (last 30 days)
Show older comments
How can I change the font size of the axes of the current graph without creating new axes? For example, if we have this plot already, how can I change the font size?
x = rand(10,10);
y = rand(10,10);
plot(x,y)
0 Comments
Accepted Answer
Matt Fig
on 28 Apr 2022 at 4:00
Edited: MathWorks Support Team
on 28 Apr 2022 at 14:06
To change the font size, set the FontSize property on the axes object after plotting. For example:
x = rand(10,10);
y = rand(10,10);
plot(x,y);
set(gca,”FontSize”,20)
Starting in R2022a, you can use the “fontsize” function to change the font size for any graphics object that has text associated with it. In this case, pass the axes object to the “fontsize” function followed by the desired font size in points. For example:
fontsize(gca,20)
You can also change the font name using the “fontname” function. The font you specify must be installed on your system. For example, change the font of the current axes to Courier:
fontname(gca,"Courier")
3 Comments
More Answers (1)
Image Analyst
on 16 May 2022 at 13:22
See attached demo to see how you can independently change a wide variety of things in your axes.

0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!