フィルターのクリア

Setting font size separately for x&y axes

8 ビュー (過去 30 日間)
z8080
z8080 2016 年 7 月 2 日
コメント済み: Star Strider 2016 年 7 月 2 日
I am using the Property Editor in Matlab 2016a to customise my plot for publication. I would like to increase the font size of my x axis labels, while leaving those of the y axis unchanged. However, the FontSize property changes both at the same time, and I did not find any separate properties for the font on the two axes. Can this be done in Property Editor, or at least is there a command-line workaround?

採用された回答

Star Strider
Star Strider 2016 年 7 月 2 日
編集済み: Star Strider 2016 年 7 月 2 日
You have to use a text object if you want to change the font size of the tick labels.
Example:
x = 1:10;
y = rand(1, 10);
figure(1)
plot(x, y)
xt = get(gca, 'XTick');
set(gca, 'XTickLabel','') % Turn Off X-Labels
xts = regexp(sprintf('%.1f ', xt), ' ','split');
fntsz = 18; % Font Size
text(xt, -(1/(10*fntsz))*diff(ylim)*ones(size(xt)), xts(1:end-1), 'FontSize', fntsz, 'HorizontalAlignment','center', 'VerticalAlignment','top')
I made this as adaptable as I could, but you will probably have to experiment with it to get the result you want.
EDIT Added separate font size variable ‘fntsz’, so the text position automatically spaces correctly w.r.t. x-axis.
  2 件のコメント
z8080
z8080 2016 年 7 月 2 日
Many thanks!
Star Strider
Star Strider 2016 年 7 月 2 日
My pleasure!
Please see the edited version. I added a separate font size variable and used it to calculate the y-coordinate of the text object so the spacing between the text object and the x-axis to automatically scale correctly, regardless of font size.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLabels and Annotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by