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