Couldn't exploit axis exponent for log scaled axis.

9 ビュー (過去 30 日間)
Mithun Sundhar B
Mithun Sundhar B 2022 年 7 月 16 日
コメント済み: Mithun Sundhar B 2022 年 7 月 17 日
I've a plot that has axis values jumping orders of magnitude, which necessitate to plot in log scale. Here is my axes values requirement:
y=[10^-8 5*10^-8 7*10^-8 4*10^-7 9*10^-7]; %y axis
x=[10^-7 10^-6 10^-5 10^-4 10^-3]; %x axis
I specifically want my y axis tick values to be [0.1 0.5 0.7 4.0 9.0] with an exponent at the top having a value of 10^-7. Editing options manually also hasn't favored me. Though I was able to set exponent mode (with value -7) and tick label mode (with format %.2f) (both manually and through code), the same is not reflected in the output for some reasons. Irrespective of many efforts, the tick values prefer to stay in the format of 10 raised to some power. What I've shown here is just a similar code, whereas in my main work the tick values set themselves to 0.00 for all the values. Scratching my head for more than two days, rescue me at the earliest. Warm regards for your kind help!
Here is my complete code for your reference.
loglog(x,y)
hold on
ax = gca;
% ax.YTickMode='manual';
ax.YTickValuesMode='manual';
ax.YTickLabelMode='auto';
ax.ExponentMode='manual';
ax.TickLabelFormatMode='manual';
yticks([10^-8 5*10^-8 7*10^-8 4*10^-7 9*10^-7])
ax.YAxis.Exponent = -7;
ytickformat('%.2f')
hold off
  2 件のコメント
Voss
Voss 2022 年 7 月 16 日
Note the documentation for NumericRuler properties (in the Exponent property section):
"If the axis has a log scale, then the Exponent property has no effect."
Mithun Sundhar B
Mithun Sundhar B 2022 年 7 月 17 日
Yeah @Voss, you're right. I couldn't convince myself with an answer of why such option is not available for axis with log scale. If you've any explanation, please shed some light. Just curious!

サインインしてコメントする。

回答 (1 件)

dpb
dpb 2022 年 7 月 16 日
You'll have to fake it -- as @Voss notes, the effect you observe (none) is by design -- whether was right choice or not is different question.
loglog(x,y)
hAx=gca;
yl=ylim;
yticklabels(num2str(yticks*1E7,'%0.1f'));
hTxt=text(x(1),yl(2),'10^{-7}','VerticalAlignment',"bottom");
results in
  1 件のコメント
Mithun Sundhar B
Mithun Sundhar B 2022 年 7 月 17 日
Thanks @dpb for a simple code structure. I did the same manually. I was just wondering why such restriction has been made for log scaled axis. Many thanks!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGraphics Object Properties についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by