help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Exponential notation in tick labels?


From: Carlo de Falco
Subject: Re: Exponential notation in tick labels?
Date: Wed, 9 Sep 2009 14:59:04 +0200

2009/9/9 Matthias Brennwald <address@hidden>:
> Thanks, this does the trick! Now I could even try to adapt this to the
> "10^n" notation... I don't know a direct way to use sprintf(...) to
> print numbers in  the 10^n format, but I guess it is feasible by
> manipulating the ticklabels using string functions somehow.


octave-3.2.2:76> x= [1e5:1e5:1e6];
octave-3.2.2:77> plot(x,x);
octave-3.2.2:78> axis tight
octave-3.2.2:79> xt = get(gca, 'xtick');
octave-3.2.2:80> x_ex = floor(log10(xt));
octave-3.2.2:81> x_mant = xt./10.^x_ex;
octave-3.2.2:82> set(gca, 'xticklabel', sprintf('%1.1fx10^{%d}|',
x_mant, x_ex));


Note that if one of the ticks were labeled "0" it would need to be
handled separately
(that's the reason for "axis tight")


> Thanks again
> Matthias
c.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]