On Thu, Mar 10, 2011 at 4:54 AM, Daniel Mader <
danielstefanma...@googlemail.com> wrote:

> Hi,
>
> is it possible to change the default y-axis scaling so that the
> ticks/label are not with respect to the large offset?
>
> For example:
>
> import scipy
> import pylab
>
> x = scipy.arange(100)
> y = scipy.rand(100) + 1000006
>
> pylab.figure()
> pylab.plot(x,y)
> pylab.grid()
>
> pylab.show()
>
> This gives the y-limits as (0,1) with respect to 1000006. This makes
> it very hard to read. I'd like to be able to configure this manually.
>
> Thanks in advance,
> Daniel
>
>
I tried to fix matplotlib to be smarter about choosing the offset value a
while back, but I couldn't come up with something that worked well in the
general case.  You can manually turn it off completely, and have the full
value displayed (or even manually set the offset value).  If you have a very
recent matplotlib:

import matplotlib.pyplot as plt
import numpy as np

x = np.arange(100)
y = np.random.rand(100) + 1000006

plt.figure()
plt.plot(x, y)
plt.grid()
plt.ticklabel_format(useOffset=1000000, axis='y')

plt.show()

Or you can turn it off by setting useOffset to False.

If you don't have a recent enough matplotlib, you can turn it off completely
by doing something like this:

import matplotlib.pyplot as plt
import numpy as np
from matplotlib.ticker import ScalarFormatter

x = np.arange(100)
y = np.random.rand(100) + 1000006

fig = plt.figure()
ax = fig.gca()
ax.plot(x, y)
ax.grid()
ax.yaxis.set_major_formatter(ScalarFormatter(useOffset=False))

plt.show()


I hope this helps!
Ben Root
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to