I am unable to change the fontsize of axis ticks
5 views (last 30 days)
Show older comments
Chandramouli Santhanam on 10 Mar 2023
Commented: Chandramouli Santhanam on 13 Mar 2023
I am using MATLAB R2021b, and would like to change the font size of tick labels of both the axes. I tried the method suggessted here However, setting the font size using gca.FontSize doesn't change the size of axis ticks. Here's a sample code:
x = rand(1,100);
y = rand(1,100);
ax = gca;
ax.FontSize = 20;
I obtain a result as shown in the attachment. Only the xlabel size is changed to 20, and that is because of the last line I guess.
Can someone help me please?
Adam Danz on 10 Mar 2023
Edited: Adam Danz on 10 Mar 2023
> setting the font size using gca.FontSize doesn't change the size of axis ticks
gca() is a function that returns the current axis handle. Unless you've used gca as a variable name, you should be getting an error (the error message below is from R2022b).
% > Unable to resolve the name gca.FontSize. - R2021b error message
You could use
Or, better yet,
ax = gca();
Find more on Axis Labels 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!