How can I change the font size of tick labels on the axes of a graph?
Show older comments
I have tried all of the suggestions in fx, Help and answers to other people's questions, but I cannot make any of them work in Matlab 2020a.
Answers (2)
Cris LaPierre
on 29 May 2020
Edited: Cris LaPierre
on 29 May 2020
plot(1:5)
ax=gca;
ax.FontSize = 20
ax.XAxis.FontSize = 20
5 Comments
David Slater
on 2 Jun 2020
Edited: Cris LaPierre
on 2 Jun 2020
Cris LaPierre
on 2 Jun 2020
Please share your full script.
David Slater
on 2 Jun 2020
Cris LaPierre
on 2 Jun 2020
You likely replied to an email notification from MATLAB Central. Replies are not actually directed to anyone.
I've poked around in your code. I didn't attempt to explore every plot, but if I were you, I would probably set the properties this way.
title(strcat('Basilar Membrane Velocity Transfer Function, Excitation @',Stringt,sprintf('\n Frequency = %0.0f Hz,',f(fn)),Comp))
ylabel(strcat('Basilar Membrane velocity amplitude (dB)',Stringy))
xlabel('Distance from Stapes (mm)')%lgd.Title.String = 'Frequency (kHz)';
ax=gca;
ax.XAxis.FontSize = 12;
ax.YAxis.FontSize = 12;
ax.XLabel.FontSize = 24;
ax.YLabel.FontSize = 14;
ax.Title.FontSize = 18;
Was there a particular plot that was not working?
Giuseppe Degan Di Dieco
on 27 Apr 2021
Dear Cris,
your solution worked for me too.
Thanks for your brilliant help.
Best!
David Slater
on 3 Jun 2020
0 votes
5 Comments
Cris LaPierre
on 3 Jun 2020
Edited: Cris LaPierre
on 3 Jun 2020
Order matters. Looking at your simple example, if you step through the code line by line, you see that the title, axis labels, and tick labels all get added as prescribed. Here, a break point was added at line 8 and I have stepped through the code line by line to line 18. Execution is paused at the green line.

In the next image, I have executed line 18, adding the semilog plot. As you can see, the semilogx plot command resets all the axes properties.

My recommendation - plot first, then modify the properties.
figure(1)
plot(1:5)
ax=gca;
ax.FontSize = 20
f=logspace(log10(20),log10(20000),100);
HL0=linspace(0,50);
figure(6)
semilogx(f,20*log10(HL0),'LineWidth', 3,'color','r')
title('Measured and Predicted Hearing Loss (Reduction in BM Velocity) with no Bubble')
ylabel('Post Implant Hearing Loss (dB)')
xlabel('Frequency (Hz)')
ax=gca;
ax.XAxis.FontSize = 20;
ax.YAxis.FontSize = 20;
ax.XLabel.FontSize = 20;
ax.YLabel.FontSize = 20;
ax.Title.FontSize = 36;
grid on

David Slater
on 4 Jun 2020
David Slater
on 6 Jun 2020
David Slater
on 10 Jun 2020
David Slater
on 1 Jul 2020
Categories
Find more on Axis Labels in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!