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

조회 수: 1,761 (최근 30일)
Gene Polovy
Gene Polovy 2015년 1월 31일
편집: Adam Danz 2024년 1월 29일
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일
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
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일
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
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!

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by