From: Matthias M. <Mat...@gm...> - 2008-03-25 10:32:07
|
Hey Chris, On Saturday 22 March 2008 03:36, Chris Withers wrote: > Matthias Michler wrote: > > maybe something like the following helps you: > > ------------------------------------------------------------------------- > >---------------- from pylab import * > > from time import sleep > > > > ion() # interactive mode 'on' > > figure() > > ax = subplot(111, autoscale_on=True) > > > > x, y = [0], [0] > > line = plot(x, y, label="my_data")[0] > > # get the line-object as the first > > element # of the tuple returned by plot legend() > > for i in arange(10): > > x.append(i) # append new values > > y.append(i**2) > > line.set_data(x,y) # reset data > > ax.relim() # reset axes limits > > ax.autoscale_view() # rescale axes > > draw() # redraw current figure > > sleep(0.5) # wait 0.5 seconds > > > > ioff() > > This is perfect, except for one little thing... > > My x-axis is time, and as new points are plotted, even though I'm > following the above recipe pretty closely, the x-tick spacing isn't > getting sorted out, so I end up with just a jumble as the tick labels > for the x-axis. Do you know why this might be? I'm not sure I understand correctly, but if the number of xticks increases dramatically (nobody could see the individual ticks), the above script leads to a different behaviour on my system. > > I don't know how to make this somehow interactive concerning the data > > input. but maybe you save the data to a file and read them every 15 or 20 > > minutes. > > This isn't a problem, I just run in a "while True" loop and leave it > running until I close the plot window. > > Shame I get that horrible exception when I do close the plot window, > wish I knew how to make it stop :-S I don't know which exception you refer to, but sometimes if gives problems if the interactive mode wasn't switched off ("ioff()") before the scripts ends or "show()" is called. regards Matthias |