On Mon, Dec 13, 2010 at 9:10 PM, Xunchen Liu <xunchen....@gmail.com> wrote:

> Hello,
>
> I'm plotting some experimental data and found my x axis variable are
> displayed like 1, 2, 3, +1000. It seems depend on how you set a stopper or
> something.
> I'm wondering how to make it display just 1001, 1002, 1003?
>
> thanks!
>

The behavior you are seeing is called "tick offset" and is controlled by the
axis tick formatter.  This can be controlled in different ways, but here is
one approach:


import numpy as np
import matplotlib.pyplot as plt

x = np.arange(1000, 1010)
y = np.random.random((10,))

fig = plt.figure()
ax = fig.gca()

ax.plot(x, y)

# Get the formatter for the major ticks of the x-axis
# and set the 'useOffset' attribute to False.
ax.get_xaxis().get_major_formatter().set_useOffset(False)

plt.show()


I hope that helps!
Ben Root
------------------------------------------------------------------------------
Lotusphere 2011
Register now for Lotusphere 2011 and learn how
to connect the dots, take your collaborative environment
to the next level, and enter the era of Social Business.
http://p.sf.net/sfu/lotusphere-d2d
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to