How can I show axis ticks as fractions?

조회 수: 12 (최근 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 CenterFile Exchange에서 Axis Labels에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by