Hello Hussein,

maybe the following example helps you. It uses the module 'time' to wait for 
some seconds.

regards Matthias

--------------- "test.dat": ----------------------------------------------
#time       x_coordinate        y_coordinate
0.1          1                              1
0.2          2                              2
0.3          3                              3
0.4          4                              4

-------------------- "... .py": 
--------------------------------------------------
from scipy.io import read_array
import pylab as pl
import numpy as npy
import time

data = read_array("test.dat")

pl.ion() # Turn interactive mode on.
pl.figure()
pl.subplot(111, autoscale_on=False)
pl.axis([0.0, 5.0, 0.0, 5.0])

# plot the first point:
point, = pl.plot([data[0, 1]], [data[0, 2]], 'b+')
pl.draw()
print "first (x, y) = ", data[0, 1:]

for i in xrange(1, npy.shape(data)[0]):
    # wait time-difference * 10 seconds
    time.sleep((data[i, 0]-data[i-1, 0])*10)
    # reset data of plotted point
    point.set_data(npy.array([data[i, 1]]), npy.array([data[i, 2]]))
    pl.draw()
    pl.draw()
    
    print "new (x, y) = ", data[i, 1:]

pl.ioff() # Turn interactive mode off. 
pl.show()
-------------------------------------------------------------------------------------------

On Sunday 20 July 2008 21:31:42 hussein alshatri wrote:
> Hi  all,
>
> I am new with matplotlib. I want to use matplotlib/animation.
>
> I want to plot a moving point. The information comes from input file that
> include columens as bellow:
>
> #time       x_coordinate        y_coordinate
>
> I have seen the examples on the website, But I don't know how to configure
> the time.
>
> Could anyone just guide me how to do this or if there is a short example it
> would be great...
>
> Thank you in advanced.
>
> Hussein

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to