3

I am using Python and Pyplot to produce a plot. The y axis of the plot is generated automatically, and works fine.

If the range is small however, the y axis will produce values such as:

0.00005,  
0.00010,  
0.00015,  
0.00020,  
0.00025,  
0.00030, 

and then at the top of the axis, will say:

+1.543e-1

I would prefer that it just explicitly shows the values:

0.15435  
0.15440  
0.15445  
0.15450  
0.15455  
0.15460  

Could someone tell me how to do this please?

Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234
user1551817
  • 6,693
  • 22
  • 72
  • 109
  • 1
    Take a look at the [ticker api](http://matplotlib.org/api/ticker_api.html), and perhaps this [example](http://matplotlib.org/examples/pylab_examples/major_minor_demo1.html#pylab-examples-major-minor-demo1) – Chris Zeh Oct 15 '13 at 15:05
  • 3
    there is a PR in the works to be able to set this as an rcparam, should be in 1.4. – tacaswell Oct 15 '13 at 15:29
  • 2
    for completeness, https://github.com/matplotlib/matplotlib/pull/2401 – tacaswell Oct 15 '13 at 15:41
  • Nice @tcaswell. I also would like that offset feature `off` by default. – Chris Zeh Oct 15 '13 at 16:01

1 Answers1

3

Alright, I think I found the total solution:

Here is a quick plot that recreates your problem:

plot((0.15435,0.15440,0.15445,0.15450,0.15455,0.15460),(0.15435,0.15440,0.15445,0.15450,0.15455,0.15460))

The following code (similar to how it was as shown here) should adjust the ticker like you want:

y_formatter = matplotlib.ticker.ScalarFormatter(useOffset=False)
gca().yaxis.set_major_formatter(y_formatter)
Community
  • 1
  • 1
Chris Zeh
  • 924
  • 8
  • 23