How can I change the font size of plot tick labels?

I am trying to change the font size of the tick labels (the numbers) in my plots. (Just to be clear, I am NOT referring to the axis labels.)

 採用された回答

Star Strider
Star Strider 2015 年 1 月 31 日
編集済み: MathWorks Support Team 2018 年 11 月 27 日

17 投票

You can change the font size of the tick labels by setting the FontSize property of the Axes object. The FontSize property affects the tick labels and any axis labels. If you want the axis labels to be a different size than the tick labels, then create the axis labels after setting the font size for the rest of the axes text.
For example, access the current Axes object using the gca function. Use dot notation to set the FontSize property for the Axes object. Then create an x-axis label with a different font size.
x = rand(1,100);
y = rand(1,100);
scatter(x,y)
ax = gca;
ax.FontSize = 16;
xlabel('My Label','FontSize',10)

9 件のコメント

Gene Polovy
Gene Polovy 2015 年 1 月 31 日
I tried this using R2014a first and it didn't work, but I happen to have 2014b on another computer (my department recently upgraded) and it worked there. Thank you! I hope MATLAB looks into this issue ...
Star Strider
Star Strider 2015 年 1 月 31 日
My pleasure! I’m glad it worked. There are version differences, so hanging out on Answers means the Questions are always something of a moving target.
(The most sincere expression of appreciation here on MATLAB Answers is to Accept the Answer that most closely solves your problem.)
Image Analyst
Image Analyst 2015 年 1 月 31 日
If what you say is true, then they have looked into it. It's fixed in the new version isn't it? You said it was.
Marzena Krzek -BIO-
Marzena Krzek -BIO- 2019 年 8 月 17 日
移動済み: Adam Danz 2024 年 1 月 26 日
i have 2019b - it doesn't work for me either
David Slater
David Slater 2020 年 5 月 29 日
移動済み: Adam Danz 2024 年 1 月 26 日
I have 2020a and it doesn't work in that version either.
Boris Touvykine
Boris Touvykine 2020 年 7 月 28 日
移動済み: Adam Danz 2024 年 1 月 26 日
This should work for 2019 & 2020
x = rand(1,100);
y = rand(1,100);
scatter(x,y)
ax = gca;
ax.YAxis.FontSize = 13 %for y-axis
In general if you want to see what properties are there for axis appearences just run
ax.YAxis
and then click on "show all propeties" in command window.
Hamid Motallebzadeh
Hamid Motallebzadeh 2020 年 12 月 2 日
移動済み: Adam Danz 2024 年 1 月 26 日
I'm using 2020b on Mac (Mojave). When I use gca.YAxis.FontSize = 40, it does not change the font size, but gca.YAxis returns
gca.YAxis
ans =
struct with fields:
FontSize: 40
It looks like it has the font size but does not apply it to the figure.
Adam Hooker
Adam Hooker 2021 年 2 月 24 日
移動済み: Adam Danz 2024 年 1 月 26 日
I too am having this problem.
Yijun Li
Yijun Li 2021 年 2 月 26 日
移動済み: Adam Danz 2024 年 1 月 26 日
same problem. I am using 2019a Windows, gca.YAxis.FontSize = 40 does not change the tick font

サインインしてコメントする。

その他の回答 (1 件)

Zaid hamamah
Zaid hamamah 2022 年 4 月 25 日
編集済み: Adam Danz 2024 年 1 月 29 日

18 投票

I know it is too late but just for the future readers: (i am using version R2021a)
1) To change the font size of all texts included of (ax) axes, such as y- and x- axes labels in addition to the title or any other text like tick labels:
ax.FontSize =
2) To change all the text attached to one specific axis: (tick labels and label)
ax.XAxis.FontSize =
3) To change only the size of the label:
ax.XLabel.FontSize =
The same goes for y-axis using:
ax.YAxis.FontSize =
ax.YLabel.FontSize =
So if you want to change the tick labels, you can use a general command like the second one, and then readjust the label specifically using the third command.
Lastly, to control the relative difference in font size between the tick labels and axis label:
ax.LabelFontSizeMultiplier =
See Axes Properties for more info.

3 件のコメント

nuri hakan aydin
nuri hakan aydin 2022 年 8 月 20 日
Very helpful, thank you!
Zong-Jhen Ye
Zong-Jhen Ye 2022 年 10 月 10 日
Thank you very much for your sharing.
Isacc Alpala
Isacc Alpala 2024 年 1 月 12 日
Really helpful. Thanks!

サインインしてコメントする。

カテゴリ

質問済み:

2015 年 1 月 31 日

編集済み:

2024 年 1 月 29 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by