フィルターのクリア

How to control latex TickLabel FontSize?

10 ビュー (過去 30 日間)
pedro
pedro 2023 年 4 月 25 日
コメント済み: pedro 2023 年 4 月 28 日
I'm trying to make a fraction into a tick label. This
set(gca, 'TickLabelInterpreter', 'latex', 'YTickLabel', {'$\frac{a}{b}$'})
puts the fraction where I want it, but it's very very small.
This
set(gca, 'TickLabelInterpreter', 'latex', 'YTickLabel', {'$\frac{a}{b}$'}, 'FontSize',20)
makes the tick label have the size I want, but also increases the title and axes labels, which become way too big.
How can I change the size of the tick label, and nothing else?

採用された回答

Adam Danz
Adam Danz 2023 年 4 月 25 日
編集済み: Adam Danz 2023 年 4 月 27 日
Two methods
Set FontSize property
figure()
ax = gca();
set(ax, 'TickLabelInterpreter', 'latex', 'YTickLabel','$\frac{a}{b}$')
ax.YAxis.FontSize = 16;
ylabel('Default label size','FontSize', ax.FontSize)
xlabel('Default label size')
Set FontSize in Latex command
To preserve normalized FontUnit behavior, you can set the fontsize directy in the Latex command. Now, when you change the figure size the title, axis labels, and ticks will resize. However, the ticks may not adjust as they would when you set the axis fontsize property.
figure()
ax = gca();
set(ax, 'TickLabelInterpreter', 'latex', 'YTickLabel', '\fontsize{16}{0}$\frac{a}{b}$')
title('title')
ylabel('xlabel')
xlabel('ylabel')
ax.FontUnits='normalized';
  5 件のコメント
Adam Danz
Adam Danz 2023 年 4 月 27 日
See the 2nd solution I added to my answer.
pedro
pedro 2023 年 4 月 28 日
Thank you Adam for your continued assistance, that solved my problem.

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

その他の回答 (0 件)

カテゴリ

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

製品

Community Treasure Hunt

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

Start Hunting!

Translated by