Customise axis ticks and ticks labels with exponential notation

조회 수: 10 (최근 30일)
Sim
Sim 2022년 8월 13일
댓글: Sim 2022년 8월 16일
How can I customise both axes to get this figure, with this exponential notation ?

채택된 답변

dpb
dpb 2022년 8월 13일
편집: dpb 2022년 8월 13일
See <Include Superscript and Subscript in Axis Labels> example at <xlabel>
Moral: Read doc including looking at examples...
  댓글 수: 3
dpb
dpb 2022년 8월 16일
You can make things a little less specific and typing of duplicated stuff using MATLAB array syntax --
p=[0:0.5:2.5]; % the desired powers
xtk=10.^p; % evaluate for ticks, limits
xlim([xtk(1) xtk(end)]) % set limits to match
xticks(xtk) % and the desired tick locations
xticklabels(compose('10^{%g}',p)) % and put on the annotation
This lets you set any arbitrary set of exponents in the p array; the rest then follows automagically...
Sim
Sim 2022년 8월 16일
I like the "automagically" term ;-)
...thanks a lot @dpb, I will use your piece of code, better than what I wrote :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

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