How can I show axis ticks as fractions?

13 ビュー (過去 30 日間)
Hamid Attar
Hamid Attar 2020 年 9 月 27 日
編集済み: madhan ravi 2020 年 9 月 27 日
Hello,
I want my Y-axis ticks to show fractional values, instead of decimal values. Ideally, I want in the range of 1/150 (lowest) to 1/50 (highest) in whole numbers. Something like [1/150, 1/125, 1/100, 1/75, 1/50] on the y axis. How can I do this?
Thanks

採用された回答

madhan ravi
madhan ravi 2020 年 9 月 27 日
編集済み: madhan ravi 2020 年 9 月 27 日
yticklabels("1/" + (150 : -25 : 50))
% or
yticklabels(compose("1/%d", (150 : -25 : 50))
% or
set(gca, 'YTickLabel', sprintfc('1/%d', (150 : -25 : 50))) % for older versions, sprintfc() undocumented
  3 件のコメント
madhan ravi
madhan ravi 2020 年 9 月 27 日
編集済み: madhan ravi 2020 年 9 月 27 日
Look at yticks()
Hamid Attar
Hamid Attar 2020 年 9 月 27 日
Thanks, this worked:
yticks( [1/150, 1/125, 1/100, 1/75, 1/50])
yticklabels("1/" + (150 : -25 : 50))

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

その他の回答 (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