Couldn't exploit axis exponent for log scaled axis.

12 visualizaciones (últimos 30 días)
Mithun Sundhar B
Mithun Sundhar B el 16 de Jul. de 2022
Comentada: Mithun Sundhar B el 17 de Jul. de 2022
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 comentarios
Voss
Voss el 16 de Jul. de 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."
Mithun Sundhar B
Mithun Sundhar B el 17 de Jul. de 2022
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!

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb el 16 de Jul. de 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
  1 comentario
Mithun Sundhar B
Mithun Sundhar B el 17 de Jul. de 2022
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!

Iniciar sesión para comentar.

Categorías

Más información sobre Graphics Object Properties en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by