フィルターのクリア

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 Center および File ExchangeAxis Labels についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by