필터 지우기
필터 지우기

Axis fontsize and text fontsize not matching

조회 수: 4 (최근 30일)
royk
royk 2018년 5월 18일
댓글: royk 2018년 5월 18일
I am using the code below that shows the same text as axis xlabel and as a text object. These two labels appear in different sizes despite both being defined at the same size (10 points). I tried on both Windows and Mac. Also in both 2017b and 2018a versions. same problem appears.
lbl = 'These two labels should have the same fontsize 10 yet appear with different sizes' ;
figure(1);clf
set(gcf,'position',[100 100 700 700])
plot([0 1],[0 1],'r')
xlabel(lbl)
text(0.5,-0.1, lbl, 'units','normalized', ...
'HorizontalAlignment','center','fontsize',10)
set(gca,'fontsize',10)

채택된 답변

Sandro Lecci
Sandro Lecci 2018년 5월 18일
편집: Sandro Lecci 2018년 5월 18일
Dear Royk,
try this:
lbl = 'These two labels should now have the same fontsize 10' ;
figure(1);clf
set(gcf,'position',[100 100 700 700])
plot([0 1],[0 1],'r')
A = xlabel(lbl);
A.FontSize = 10;
text(0.5,-0.1,lbl,'units','normalized','HorizontalAlignment','center','fontsize',10);
best, Sandro
  댓글 수: 1
royk
royk 2018년 5월 18일
thanks! that works and i like also the short version of Jan But: what then is the meaning of the fontsize of the axis itself?

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

추가 답변 (1개)

Jan
Jan 2018년 5월 18일
lbl = 'These two labels should have the same fontsize 10 yet appear with different sizes' ;
figure('position', [100 100 700 700])
plot([0 1], [0 1], 'r');
xlabel(lbl, 'FontSize', 10);
text(0.5, -0.1, lbl, 'units','normalized', ...
'HorizontalAlignment', 'center', 'fontsize', 10)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

제품


릴리스

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by