필터 지우기
필터 지우기

After we we set up a range in a given X axis, how can we have the labels be in exponential form 10^power at each tick mark, not as a single multiplier x10^power?

조회 수: 4 (최근 30일)
ax1.FontSize = 17;
ax1.Units = 'normalized';
ax1.XColor = 'k';
ax1.XScale = 'log'; %'linear' % see Axes Properties
ax1.XTick = logspace(log10(nOut(2)),log10(nOut(end)),5); %Define the Numbers in the X axis (Log 0 is Inf number, so start from second nOut)
ax1.XTick = round(ax1.XTick*2)/2;
ax1.XAxis.TickLabelFormat = '%.2f'; %Define the decimal places in the Numbers displayed in the X-axis
The numbers in the x axis are displayed as decimals. See Attached picture
  댓글 수: 2
dpb
dpb 2021년 12월 19일
편집: dpb 2021년 12월 20일
ax1.XAxis.TickLabelFormat = '%.2f';
"The numbers in the x axis are displayed as decimals."
Yes, that's what you told it to do.
MATLAB doesn't label ticks other than the major divisions on log axes for precisely this reason...you'll have to create amd write the tick labels yourself...
A quick spearmint here to see if works as intended without all the niceties shows can be made to happen with sufficient work...
x=logspace(-3,3);
y = 5 + 3*sin(x);
loglog(x,y)
xtk=[0.5 4.5,34.5,260].';
xticks(xtk)
xticklabels(compose('%.2f*10^{%d}',(xtk./10.^ceil(log10(xtk))),ceil(log10(xtk))))
results in the crude starting point ...
Of course, when you write those, you'll obliterate any MATLAB has written at the default loctions unless you're also careful to not overwrite them. Here, at least, you've turned those off anyways, but wouldn't think that would be desireable in general.

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

답변 (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