# plot a moving point from an input file

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...

Hussein

···

_________________________________________________________________
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

I would like to know how to plot a stationary point. Do you know how to plot
a stationary point?? I will also be interested in plotting a moving point;
so I'll be interested in this post.

<
I want to plot a moving point. The information comes from input file that
include columens as bellow:

#time x_coordinate y_coordinate

···

--
View this message in context: http://www.nabble.com/plot-a-moving-point-from-an-input-file-tp18557820p18558156.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

from pylab import *

def point(x,y):
a=arange(x,x+1,1)
b=arange(y,y+1,1)

plot(a,b, 'ro', ms=3)

show()

This works for me.

Run it by typing point(x,y), where x and y are the coordinates you'd like to
see in a plot, and a magical red "point" will appear in your matplotlib
figure. You can change the color and size, of course, by modifying the color
('ro') and markersize ('ms= 3') keyword arguments to suit your needs.

Now just put in a t parameter, I guess.

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...

Hussein
_________________________________________________________________
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/

-------------------------------------------------------------------------
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

--
View this message in context: http://www.nabble.com/plot-a-moving-point-from-an-input-file-tp18557820p18562838.html
Sent from the matplotlib - users mailing list archive at Nabble.com.

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": --------------------------------------------------
import pylab as pl
import numpy as npy
import time

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...

Hussein

A note of caution: this example will probably only work with tkagg.
For other GUIs, like gtk, wx, or qt, you will probably want to use a
timeout handler.

JDH

···

On Mon, Jul 21, 2008 at 2:57 AM, Matthias Michler <MatthiasMichler@...361...> wrote:

Hello Hussein,

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