how to plot stepwise lines

Hello,
  I want to plot a stepwise line using
plot([1,2,3,4,5],[2,-2,2,-2,2]). But what I get is something like two
triangular like shape. But I want a stepwise shape that has steep
vertical jumps. How can I do that?
Many thanks,
Zhang Le

I want to plot a stepwise line using
plot([1,2,3,4,5],[2,-2,2,-2,2]). But what I get is something like two
triangular like shape. But I want a stepwise shape that has steep
vertical jumps. How can I do that?

this what you mean?

#!/usr/bin/env python
from pylab import *

plot([1,2,3,4,5],[2,-2,2,-2,2], linestyle='steps')
gca().set_ylim( (-3, 3))
show()

···

Many thanks,
Zhang Le

-------------------------------------------------------
SF.Net email is sponsored by:
Tame your development challenges with Apache's Geronimo App Server. Download
it for free - -and be entered to win a 42" plasma tv or your very own
Sony(tm)PSP. Click here to play: http://sourceforge.net/geronimo.php
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

--
Peter Groszkowski Gemini Observatory
Tel: +1 808 9742509 670 N. A'ohoku Place
Fax: +1 808 9359235 Hilo, Hawai'i 96720, USA

It sounds like you want step_pts from
http://www.american.edu/econ/pytrix/pytrix.py
Maybe.
Alan Isaac

def step_pts(x, y):
  '''Given x and y, return points for step function plot.

  :Parameters:
   - `x`: [x0,x1,...,xn] list of x values (first coordinate)
   - `y`: [y0,y1,...,yn] list of y values (second coordinate)
  :rtype: tuple of lists
  :return: (xnew,ynew)
    where xnew=(x0,x1,x1,...,xn,xn) and ynew=(y0,y0,y1,y1,...,yn).
  :author: Alan G. Isaac
  :since: 2005-05-15
  '''
  pts=zip(x,y) #original points as tuples
  inter = zip(x[1:],y[:-1]) #new points as tuples
  #now splice pts and inter -> list of all points as tuples
  pts_inter = [j for i in map(None,pts,inter) for j in i][:-1]
  #split the points list into (x-coordinates),(y-coordinates)
  z = zip(*pts_inter)
  return z[0],z[1]