[Top][All Lists]

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

Re: Exponential notation in tick labels?

From: Ben Abbott
Subject: Re: Exponential notation in tick labels?
Date: Wed, 09 Sep 2009 09:05:20 -0400

On Wednesday, September 09, 2009, at 08:35AM, "Matthias Brennwald" 
<address@hidden> wrote:
>On Sep 9, 2009, at 2:10 PM, Carlo de Falco wrote:
>> 2009/9/9 Matthias Brennwald <address@hidden>:
>>> Dear all
>>> I'm sure this has been discussed before, but I couldn't find anything
>>> (maybe I did not chose the right search terms). I'd like to use
>>> exponential notation for tick-mark labels in plots. For instance  
>>> "plot
>>> ([0:1e4:1E6])" yields a plot with y-axis labels 0, 200000, 400000,
>>> 600000, 700000, 1e+6. I'd like these to be 0, 2e5, 4e5, 6e5, 8e5,  
>>> 1e6.
>>> Or, even better, 0, 2x10^5, 4x10^5,..., 10^6. How can I achieve this?
>> octave-3.2.2:40> plot ([0:1e2:1e6])
>> octave-3.2.2:41> xt = get(gca, 'xtick');
>> octave-3.2.2:42> yt = get(gca, 'ytick');
>> octave-3.2.2:43> set(gca, 'xticklabel', sprintf('%1.1e|', xt));
>> octave-3.2.2:44> set(gca, 'yticklabel', sprintf('%1.1e|', yt));
>> HTH,
>> c.
>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.
>Thanks again

If you're looking to fix a single figure ...

yt = '0|2\cdot{10^5}|4\cdot{10^5}|6\cdot{10^5}|8\cdot{10^5}|10^6';
set (gca, "yticklabel", yt)


reply via email to

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