[BangPypers] 2D plotting libraries.

Noufal Ibrahim noufal at gmail.com
Fri Jun 4 09:08:45 CEST 2010


On Fri, Jun 4, 2010 at 12:13 PM, Shiv Shankar <fslash8 at gmail.com> wrote:
> Hello,
>
> I have a finite 2 dimensional plane. I have a set of co-ordinates, which is
> basically the movement of an object.
> The co-ordinates are derived from a set of equations considering various
> factors.
> After a set of initial research and tryouts i *quickly *decided on using *
> pygame* to plot the co-ordinates on a 2D plane.

PyGame is better if you want to animate rather than to plot. It has an
animation loop inside which you can update sprites and things. If you
want to see your object move as per your equations, it's pretty easy
to do. I have an example program here which you can customise.
http://github.com/nibrahim/Devious-machinations/blob/master/tutorials/positioning_sprites.py

You'll have to change the update method of the Ball to set the x and y
based on your equations rather than just x+=2, y+=0.5 which I've done.


> Has any one in here implemented this sort of a program ? Which library did
> you use ? if possible could you explain why you chose the particular
> library.

If I wanted to plot, I'd write the program to dump out the X and Y
coordinates in plain text and pipe that through Gnuplot after some
massaging to do the plot.
If you want to stuff the whole thing in Python, you simply use a
Tkinter canvas. It has some simple primitives to draw points at x and
y positions. Should be doable in 10 or 15 lines of code.




-- 
~noufal
http://nibrahim.net.in


More information about the BangPypers mailing list