Cheng-Kong Wu wrote:
> Dear all,
> 
> I have the following data:
> X = [0.0, 1.0, 3.0, 6.0, 10.0, 15.0]
> Y = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
> 
> I can plot the X-Y curve without problem.
> 
> But is there a way for me to make the xticks spaced
> evenly? That is, the distance between 0.0 and 1.0, 1.0
> and 3.0, 3.0 and 6.0, ... along the x-axis are the
> same.

What you are really doing, then, is plotting Y not against X but against 
an index, like this:

from pylab import *
X = [0.0, 1.0, 3.0, 6.0, 10.0, 15.0]
Y = [0.0, 1.0, 2.0, 3.0, 4.0, 5.0]
xi = arange(len(X))
xtlabel = ['%.1d'%x for x in X] # or [str(x) for x in X]
plot(xi, Y)
ax = gca()
ax.set_xticks(xi)
ax.set_xticklabels(xtlabel)
show()

Is this what you want?

Eric


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to