Problem changing tick label font size

Hello!
I am trying to change the size of the tick labels in a plot in matlab using the following code:
ax = gca;
ax.FontSize = 40;
This seems to work for most people on this forum, but when I try it, the font size in the tick labels in the figure does not change. However, when I enter
ax.FontSize
in the command window, it returns:
Can someone please explain to me why Matlab seems to store the change in font size, but the font size doesn't actually change in the figure? Thanks! I am using Matlab R2022a

댓글 수: 4

Adam Danz
Adam Danz 2023년 6월 12일
What interpreter are you using?
Owen Brandriss
Owen Brandriss 2023년 6월 12일
@Adam Danz I believe I am using the default, which I think is tex? Not completely sure how to check the interpereter or change it for the axes tick labels
Can you give a minimal example of some code where this does not work as expected?
Is it the case that even this simplest possible version does not work for you, on a brand-new MATLAB session?
ax = gca;
ax.FontSize = 40;
Perhaps you have a lingering set of axes around that ax is referring to, such that you are not manipulating the axes you think?
Also experiment with
FIG = get(groot, 'CurrentFigure');
AX = get(FIG, 'CurrentAxes');
set(AX, 'FontSize', 40)

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

답변 (1개)

Adam Danz
Adam Danz 2023년 6월 13일

0 개 추천

We don't have enough information to troublehoot.
One possibility is that the fontsize is not being applied to the intended axes. This could happen if the axes are within a figure with HandeVisibility turned off (e.g. uifigures). In this case, gca will not return the axes within the figure.
To avoid this possibility, instead of relying on gca(), specify the axes handle,
fig = uifigure();
ax = uiaxes(fig);
ax.FontSize = 40;
If this does not solve the problem, providing more information may help.

카테고리

도움말 센터File Exchange에서 Axis Labels에 대해 자세히 알아보기

질문:

2023년 6월 12일

답변:

2023년 6월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by