TickLabelFormat with exponential format without precision

조회 수: 4 (최근 30일)
syrup
syrup 2019년 1월 30일
답변: Ignacio Barranco Granged 2021년 5월 18일
I would like to make a plot with x-y axes in exponential format with 0 precition, i.e., 10^{n}. If I used
ax.XAxis.TickLabelFormat='%0.0e",
matlab gives me a figure in a style of 1x10^{n}. I would like to remove "1x". If I use
ax.XAxis.TickLabelFormat='%g",
matlab sometimes gives me the format of "10^{n}" but sometimes it becomes like "0.00001".
How can I fix this format in "10^{n}"?

답변 (5개)

Walter Roberson
Walter Roberson 2019년 1월 30일
ax.XAxis.Exponent = 0;
A value of 0 is default when there is not much data, but when you specifically set the value of 0 then ax.XAxis.ExponentMode becomes 'manual' so it would know not to override the setting.

syrup
syrup 2019년 1월 30일
Thanks for your answer. But this was not what I inteded. My figure is log plot and the current xticklabel is
{1x10^{-2} 1x10^{-1} 1x10^{0} 1x10^{1} }
Iwould like to change this into
{10^{-2} 10^{-1} 10^{0} 10^{1} }
  댓글 수: 2
Walter Roberson
Walter Roberson 2019년 1월 30일
Ah. In that case you will need to set xticks yourself, and you will need to set xtickslabels yourself. You cannot use TickLabelFormat for this purpose.
syrup
syrup 2019년 1월 31일
Thanks for your comments. I will make xticklabels manually.

댓글을 달려면 로그인하십시오.


Luna
Luna 2019년 1월 30일
편집: Luna 2019년 1월 30일
just use logaritmic axis with semilogx:
i = 1:10;
x = 10.^i;
y = rand(1,numel(x));
figure;
hPlot = semilogx(x,y);
Here is the link: semilogx

syrup
syrup 2019년 1월 31일
Thank you for your comments. Unfortunarly, even if I use "semilogx", the xtick sometimes becomes 0.01.
  댓글 수: 3
Luna
Luna 2019년 1월 31일
Maybe latex interpreter looks better if you want. It does not give 10^2 but shows .
set(gca,'TickLabelInterpreter', 'LaTeX');
syrup
syrup 2019년 1월 31일
Thanks. But this does not change the precision of xtick label again. Anyway, I will change the xtick format manually.

댓글을 달려면 로그인하십시오.


Ignacio Barranco Granged
Ignacio Barranco Granged 2021년 5월 18일
I have a similar issue. I have various subplots, I use the same code to generate all of them (specifying the ticks), but I do not know why in the first one the axis is shown as 1x10^ while on the rest of subplots is only 10^.
Have you managed to find a solution?
Thanks!

카테고리

Help CenterFile Exchange에서 Grid Lines, Tick Values, and Labels에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by