easiest way to plot x,y graphically during run-time?

E

Esmail

Hi all,

I am trying to visualize a number of small objects moving over
a 2D surface during run-time. I was wondering what would the easiest
way to accomplish this using Python? Ideally I am looking for a shallow
learning curve and efficient implementation :)

These objects may be graphically represented as dots, or preferably
as small arrow heads/pointy triangles moving about as their x,y
coordinates change during run-time.

Thanks,
Esmail
 
D

Diez B. Roggisch

Esmail said:
Hi all,

I am trying to visualize a number of small objects moving over
a 2D surface during run-time. I was wondering what would the easiest
way to accomplish this using Python? Ideally I am looking for a shallow
learning curve and efficient implementation :)

These objects may be graphically represented as dots, or preferably
as small arrow heads/pointy triangles moving about as their x,y
coordinates change during run-time.

pygame certainly suited, but also Tk with it's canvas-object.

Diez
 
E

Esmail

Hello Diez,
pygame certainly suited, but also Tk with it's canvas-object.

I used pygame a long time ago, barely remember it, but I think
it was pretty easy to use.

Tk seems a bit more complex .. but I really don't know much about
it and its interface with Python to make any sort of judgments as
to which option would be better.

Thanks for the suggestions, I'll take a look,

Esmail
 
E

Esmail

Gökhan SEVER said:
I don't know how easy to use pygame or pyOpenGL for data animation
comparing to Mayavi.

Mayavi uses VTK as its visualization engine which is an OpenGL based
library. I would like to learn more about how alternative tools might be
beneficial say for example atmospheric particle simulation or realistic
cloud simulation.

I've just started to read more about Particle Swarm Optimization and
since I plan to implement this in Python, I thought it would be nice
to visualize the process too, without spending too much on the nitty
gritty details of graphics.
Esmail, you may ask your question in Matplotlib users group for more
detailed input.

good idea, thanks,

Esmail
 
M

Mensanator

Hi all,

I am trying to visualize a number of small objects moving over
a 2D surface during run-time. I was wondering what would the easiest
way to accomplish this using Python?

Try Turtle Graphics using goto's. With pen up! :)
 
E

Esmail

ma said:
Try out PyChart, it's a very complete and has a great interface. I use
it to generate statistics for some of our production machines:
http://home.gna.org/pychart/

Thanks for the suggestion and link, I'm not familiar with this, but
will check it out.

If I can get matlibplot to work it would be fine since I've already
used it a bit before - so there would be less of a learning curve.

Regards,
Esmail
 
E

Esmail

Scott said:
This should look pretty easy:

Thanks Scott for taking the time to share this code with me, it
will give me something to study. I'm not sure if I'd say it looks
easy (but then again I am not very familiar with Tk :)

Best,
Esmail
 
P

Peter Pearson

On Thu, 04 Jun 2009 03:29:42 -0500, Nick Craig-Wood wrote:
[snip]
Here is a demo with pygame...
[snip]

And just for completeness, here is a demo with PyGUI, written
in similar style. (I'm a PyGUI newbie, so constructive criticism
would be appreciated.)

from GUI import Window, View, application, Color, Task
from random import randrange

class Brownian( View ):

def __init__( self, **kwargs ):
View.__init__( self, **kwargs )
width, height = self.size
self.dots = [ (randrange(width), randrange(height))
for _ in range( 100 ) ]

def step( self ):
self.dots = [ (dot[0]+randrange(-1,2), dot[1]+randrange(-1,2))
for dot in self.dots ]
self.invalidate()

def draw( self, canvas, rectangle ):
canvas.set_backcolor( Color( 0, 0, 0 ) )
canvas.set_forecolor( Color( 0.3, 0.85, 0.25 ) )
radius = 10
canvas.erase_rect( rectangle )
for dot in self.dots:
canvas.stroke_oval( ( dot[0]-radius, dot[1]-radius,
dot[0]+radius, dot[1]+radius ) )


def main():

size = 640, 480
win = Window( size = size, title = "A test of PyGUI" )
b = Brownian( size = size )
win.add( b )
win.show()
t = Task( b.step, interval = 0.02, repeat = True, start = True )
application().run()

if __name__ == "__main__":
main()
 
E

Esmail

Scott said:
I threw in too much, I think.

:)

Tk seems quite capable, perhaps a bit more than I need for my
simple visualization task at the moment (visualizing a PSO), but
I'll probably investigate it when I have more ambitious GUI needs
or am doing more than plotting the movement of particles on a 2D
surface.

Thanks again for sharing your code and explanations with me, a
great way to learn.

Esmail
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,680
Members
48,796
Latest member
Greg L.

Latest Threads

Top