Re: [Matplotlib-users] plotting numbers on axes in scientific notation

2008-10-04 Thread Eric Firing
Eric Firing wrote:
> Fabrice Silva wrote:
>> Le mardi 09 septembre 2008 à 08:26 -0400, Michael Droettboom a écrit :
>>> You can use
>>>
>>> def ticklabel_format(self, **kwargs):
>> It did not figure how to use that!
>> I've tried in ipython :
>> import numpy as np
>> t = np.linspace(0,1,1024)
>> f = np.sin(10*t)/1e5
>> plot(t,f)
>> ax = gca()
>> ax.ticklabel_format(style='sci', axis='y')
> 
>ax.yaxis.major.formatter.set_powerlimits((0,0))
> 
>> show()
>>
>> but the yticklabels are still in plain notation...
>> I've googled, but I still can not find where I am wrong!
> 
> Yes, this is confusing. The problem is that the "scientific" style uses 
> scientific notation only for sufficiently large or small numbers, with 
> thresholds determined by the powerlimits parameter.  The line I added 
> above will force scientific notation.
> 
> The ticklabel_format method needs another kwarg to enable setting the 
> powerlimits.

Done in svn 6148.  I called the kwarg 'scilimits' to emphasize that it 
works with the 'sci' style; if there are comments to the effect that I 
should have called it 'powerlimits' for consistency with the 
corresponding ScalarFormatter method, I can change it.

With the change in svn, instead of the line I added above, your call to 
ticklabel_format would be:

ax.ticklabel_format(style='sci', scilimits=(0,0), axis='y')

Eric


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting numbers on axes in scientific notation

2008-10-04 Thread Eric Firing
Fabrice Silva wrote:
> Le mardi 09 septembre 2008 à 08:26 -0400, Michael Droettboom a écrit :
>> You can use
>>
>> def ticklabel_format(self, **kwargs):
> It did not figure how to use that!
> I've tried in ipython :
> import numpy as np
> t = np.linspace(0,1,1024)
> f = np.sin(10*t)/1e5
> plot(t,f)
> ax = gca()
> ax.ticklabel_format(style='sci', axis='y')

   ax.yaxis.major.formatter.set_powerlimits((0,0))

> show()
> 
> but the yticklabels are still in plain notation...
> I've googled, but I still can not find where I am wrong!

Yes, this is confusing. The problem is that the "scientific" style uses 
scientific notation only for sufficiently large or small numbers, with 
thresholds determined by the powerlimits parameter.  The line I added 
above will force scientific notation.

The ticklabel_format method needs another kwarg to enable setting the 
powerlimits.

Eric


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting numbers on axes in scientific notation

2008-10-04 Thread Fabrice Silva
Le mardi 09 septembre 2008 à 08:26 -0400, Michael Droettboom a écrit :
> You can use
> 
> def ticklabel_format(self, **kwargs):
It did not figure how to use that!
I've tried in ipython :
import numpy as np
t = np.linspace(0,1,1024)
f = np.sin(10*t)/1e5
plot(t,f)
ax = gca()
ax.ticklabel_format(style='sci', axis='y')
show()

but the yticklabels are still in plain notation...
I've googled, but I still can not find where I am wrong!
-- 
Fabrice Silva <[EMAIL PROTECTED]>
LMA UPR CNRS 7051


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] plotting numbers on axes in scientific notation

2008-09-09 Thread Michael Droettboom
You can use

def ticklabel_format(self, **kwargs):
"""
Convenience method for manipulating the ScalarFormatter
used by default for linear axes.

Optional keyword arguments:

  ===   =
  Keyword   Description
  ===   =
  *style*   [ 'sci' (or 'scientific') | 'plain' ]
plain turns off scientific notation
  *axis*[ 'x' | 'y' | 'both' ]
  ===   =

Only the major ticks are affected.
If the method is called when the
:class:`~matplotlib.ticker.ScalarFormatter` is not the
:class:`~matplotlib.ticker.Formatter` being used, an
:exc:`AttributeError` will be raised with no additional error
message.

Additional capabilities and/or friendlier error checking may
be added.

"""

anirudh vij wrote:
> Hi,
>
> How can I plot numbers on the x and y axes in scientific notation?
>  I have very large values on the y axis which I'd like to show as 1e9 
> and not 1 followed by 9 zeros.
>
>
> 
>
> -
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> 
>
> ___
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>   

-- 
Michael Droettboom
Science Software Branch
Operations and Engineering Division
Space Telescope Science Institute
Operated by AURA for NASA


-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


[Matplotlib-users] plotting numbers on axes in scientific notation

2008-09-07 Thread anirudh vij
Hi,

How can I plot numbers on the x and y axes in scientific notation?
 I have very large values on the y axis which I'd like to show as 1e9 and
not 1 followed by 9 zeros.
-
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users