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

6 ビュー (過去 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')
  1 件のコメント
Gianluca Regina
Gianluca Regina 2021 年 3 月 17 日
This works perfectly, thank you!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSubplots についてさらに検索

製品


リリース

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by