TickLabelFormat with exponential format without precision
Ältere Kommentare anzeigen
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}"?
Antworten (5)
Walter Roberson
am 30 Jan. 2019
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
am 30 Jan. 2019
0 Stimmen
2 Kommentare
Walter Roberson
am 30 Jan. 2019
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
am 31 Jan. 2019
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
am 31 Jan. 2019
0 Stimmen
3 Kommentare
Walter Roberson
am 31 Jan. 2019
Bearbeitet: Walter Roberson
am 31 Jan. 2019
This is why you should set xticks and xticklabels yourself.
Luna
am 31 Jan. 2019
Maybe latex interpreter looks better if you want. It does not give 10^2 but shows
.
set(gca,'TickLabelInterpreter', 'LaTeX');
syrup
am 31 Jan. 2019
Ignacio Barranco Granged
am 18 Mai 2021
0 Stimmen
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!
Kategorien
Mehr zu Annotations finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!