[Matplotlib-users] Change axis's scale

2010-04-01 Thread timothee cezard
Hi all,
I have several graph to create and the position on the x axis can vary 
quite a lot.
Most of the time I'm quite happy with the default behavior but when my x 
values are very high matplotlib automatically change the ticks and set a 
scale on the axis (see screenshot) 
http://img6.imageshack.us/img6/6834/chab052195802198642shif.png
I looking for a way to change the default behavior to get a scale in 
10E** instead of some random scale.
Is there a simple way of doing that?

Thanks a lot for your help

Tim

-- 
The University of Edinburgh is a charitable body, registered in
Scotland, with registration number SC005336.


--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


Re: [Matplotlib-users] Change axis's scale

2010-04-01 Thread Matthias Michler
On Thursday 01 April 2010 12:27:59 timothee cezard wrote:
 Hi all,
 I have several graph to create and the position on the x axis can vary
 quite a lot.
 Most of the time I'm quite happy with the default behavior but when my x
 values are very high matplotlib automatically change the ticks and set a
 scale on the axis (see screenshot)
 http://img6.imageshack.us/img6/6834/chab052195802198642shif.png
 I looking for a way to change the default behavior to get a scale in
 10E** instead of some random scale.
 Is there a simple way of doing that?

 Thanks a lot for your help

 Tim

Hi Tim,

the random scale you are observing is the originalscale, where some useful 
offset has been substracted and is shown in the lower right.
You can circumvent this behaviour by using your own Formatter like a 
ScalarFormatter withour offset:
  formatter = plt.ScalarFormatter(useOffset=False)
Furthermore you can switch off the scientific formatting (extracting a common 
prefactor) using
  formatter.set_scientific(False)
Applying this formatter to the current axes:
  plt.gca().xaxis.set_major_formatter(formatter)

or a string-formatter like
  majorFormatter = plt.FormatStrFormatter('%.5e')
or
 majorFormatter = plt.FormatStrFormatter('%g')

Kind regards,
Matthias

PS: By the way, you should start a new thread for a new topic (sending a new 
mail to mpl-users) instead of responding to another message.

--
Download Intel#174; Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
___
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users