Real time plotting for serial data

Hi,

I have got my data coming in the serial port as charecters, there decimal ascii value is what I would like to plot in real time, but i get some errors and can't figure out what im doing incorrectly and am seeking some guidance,

Yours Gratefully

David

ps :- please find my code below -

···

###########################################################

import time
import pylab
import serial

pylab.ion()
timefig = pylab.figure(1)
timesub = pylab.subplot(111)
dt = 1
ser = serial.Serial(0)

t = pylab.arange(0.0, 2.0, dt)
print t
b = ord(ser.read())
print b
lines = pylab.plot(t,b)

while 1:
  t = t + dt

  print "hello"

  x = ord(ser.read())

  b.append(x)
  print b

  lines[0].set_data(t,b)
  timesub.set_xlim((t[0],t[-1]))
  pylab.draw()
  time.sleep(1.0)

ser.close()

###########################################################