Couldn't exploit axis exponent for log scaled axis.

조회 수: 12 (최근 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 CenterFile Exchange에서 Graphics Object Properties에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by