It sounds like you want step_pts from
http://www.american.edu/econ/pytrix/pytrix.py
Maybe.
Alan Isaac
def step_pts(x, y):
=09'''Given x and y, return points for step function plot.
=09:Parameters:
=09 - `x`: [x0,x1,...,xn] list of x values (first coordinate)
=09 - `y`: [y0,y1,...,yn] list of y values (second coordinate)
=09:rtype: tuple of lists
=09:return: (xnew,ynew)
=09=09where xnew=3D(x0,x1,x1,...,xn,xn) and ynew=3D(y0,y0,y1,y1,...,yn).
=09:author: Alan G. Isaac
=09:since: 2005-05-15
=09'''=20
=09pts=3Dzip(x,y) #original points as tuples
=09inter =3D zip(x[1:],y[:-1]) #new points as tuples
=09#now splice pts and inter -> list of all points as tuples
=09pts_inter =3D [j for i in map(None,pts,inter) for j in i][:-1]
=09#split the points list into (x-coordinates),(y-coordinates)
=09z =3D zip(*pts_inter)=20
=09return z[0],z[1]
|