How can I use XTickLabel with a bigger font in a subplot

조회 수: 3 (최근 30일)
Gianluca Regina
Gianluca Regina 2021년 3월 17일
댓글: Gianluca Regina 2021년 3월 17일
Dear MatLab users,
I have a tiny graphic problem. I am using a subplot(1 , 2 , 1) and (1,2,2) type, and I would like my XTickLabel being in decimal and with a relatively large fontsize. However, in the example below, which uses the same format of the plot that I need, if I put the fontsize_axis equal or greater than 19, the command XTickLabel does not work anymore, meaning that it puts the label in the wrong order. However, there is enough space for the fontsize to be at least 22 and more. Is there a way to fix this or do it in another way? I can use " set(gca,'XLim',[0.001 1], 'XTick', 10.^(-3:0))" instead, but I do not want it in exponential notation.
a = 10*rand(1,5);
b = rand(1,5);
fontsize_axis = 19 ;
subplot(1 , 2 , 1)
semilogx(a,b)
axis([0.001 10 0 1])
set(gca ,'Fontsize', fontsize_axis ,'FontWeight','bold')
ax = gca ;
ax.XTickLabel={'0.001' , '0.01' , '0.1' ,'1' , '10'};
set(gcf , 'color','w' , 'WindowState' , 'Maximize')

채택된 답변

Jan
Jan 2021년 3월 17일
Problems occur, if the number of XTicks differs from the number of XTickLabels. So set both:
a = 10*rand(1,5);
b = rand(1,5);
fontsize_axis = 19 ;
subplot(1 , 2 , 1)
semilogx(a,b)
axis([0.001 10 0 1])
set(gca ,'Fontsize', fontsize_axis ,'FontWeight','bold', ...
'XTickLabel', {'0.001' , '0.01' , '0.1' ,'1' , '10'}, ...
'XTick', [0.001, 0.01, 0.1, 1, 10]);
set(gcf , 'color','w' , 'WindowState' , 'Maximize')

추가 답변 (0개)

카테고리

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

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by