Couldn't exploit axis exponent for log scaled axis.
12 views (last 30 days)
Show older comments
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 Comments
Voss
on 16 Jul 2022
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."
Answers (1)
dpb
on 16 Jul 2022
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

See Also
Categories
Find more on Graphics Object Properties in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!