axes tick in scientific notation
31 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi,
do you know if I can set axes ticks using the scientific notation (i.e. 0.001=1e-3)? The problem is to get the same result if you do 'plot([1:0.1:2]*1e-6)', so that the 'x 10^-6' is outside the tick. 'set(gca, 'ytickLabel',[1:0.1:2]*1e-6)' does not make the same result... How I can reach the same result manually?
2 comentarios
Jan
el 23 de Mayo de 2011
Please explain it again: The "same" result as what? What do you want to appear at the ticks and do you want a common factor to be displayed on top of the axis? "1e-3" is not the "scientific notation", "1e-003" is.
Respuestas (3)
Walter Roberson
el 24 de Mayo de 2011
The scientific notation label will only automatically appear if you have not set the YTickLabel property. If you set YTickLabel, then there is no (documented) way to get MATLAB to automatically put in the exponent the same way.
In order to get around this, if you set YTickLabel and you want the exponent, you need to text() the exponent where you want it to appear.
0 comentarios
Kelly Kearney
el 23 de Mayo de 2011
figure;
plot([1:0.1:2]*1e-6;
tick2text('axis', 'y', 'yformat', '%g', 'ytickoffset', .05);
or for true scientific notation:
fun = @(x) sprintf('%g \\times 10^{%d}', ...
x/(10.^floor(log10(x))), floor(log10(x)));
figure;
plot([1:0.1:2]*1e-6;
tick2text('axis', 'y', 'yformat', fun, 'ytickoffset', .06);
EDIT: To add some text to the axis, rather than to the ticks:
text(0, 1, 'some text', 'horiz', 'left', ...
'vert', 'bottom', ...
'units', 'normalized');
The use of normalized units keeps the text in the same location, even if you change the axis limits. If you want the text to reflect the order of magnitude of the axis limits, you may need to do some of the log10 processing demonstrated above first.
3 comentarios
Kelly Kearney
el 24 de Mayo de 2011
Ah, I misunderstood what you were asking for. As Walter suggests, you can manually place text where you need it. Rereading your example, I'm still not quite sure how you want the ticks themselves to appear, but I've modified my answer above to also show how to add some text; modify to suit you purposes.
Ver también
Categorías
Más información sobre Annotations 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!