How to format YTickLabel with x10^n on when plotting a figure?

조회 수: 7 (최근 30일)
Albert Bing
Albert Bing 2016년 3월 24일
답변: Sean de Wolski 2018년 1월 8일
How to set the decimal digits of YTickLabel in figure? I tried some ways, but numbers with '%.4f' was too long, numbers with '%.2e' not good, either.
The following figure may be helpful for my question.
The left one uses
set (gca, 'YTickLabel', num2str (get (gca, 'YTick').' , '%.4f) )
The central one uses
set (gca, 'YTickLabel', num2str (get (gca, 'YTick').' , '%.2e) )
And the right one uses the default settings.
What I really want is as following figure.

채택된 답변

Sean de Wolski
Sean de Wolski 2018년 1월 8일
y = rand(10,1)*5000;
ax = axes;
plot(y)
ax.YAxis.Exponent = 3;

추가 답변 (1개)

Danesh Bankwala
Danesh Bankwala 2018년 1월 8일
편집: Danesh Bankwala 2018년 1월 8일
Did you ever figure this out? I have a similar problem.

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by