Simple raster graphics ? How do I ...

John Hunter jdhunter at ace.bsd.uchicago.edu
Wed Mar 24 15:41:52 EST 2004


>>>>> "Ray" == Ray Molacha <ray_molachaNOSPAM at gmx.co.uk> writes:

    Ray> Hi Everybody.  I'm learning Python on a Windows computer,
    Ray> using PythonWin.

    Ray> I'd like to be able to do some simple raster graphics, like
    Ray> clearing the screen and plotting a point of some color. I
    Ray> want to plot some fractals and math functions just for fun. I
    Ray> understand the math ok -- I don't know how to do simple
    Ray> raster graphics.

matplotlib may do what you want - http://matplotlib.sourceforge.net.
If you take fractal data and load it into an MxN Numeric array, you
can display it with a colormap with the plotting command imshow (image
show).

To plot simple math functions, you can do things like

  t = arange(0.0, 1.0, 0.01)
  plot(t, sin(2*pi*t))

It's not a low level drawing program, but it is a high level plotting
program that may do what you need.  You can use it to create simple
images to view in the viewer of your choice, or use of the GUI
interfaces (GTK, WX, Tk) and to view your figure with navigation
controls.

Check the screenshots section for samples plots and the scripts that
produced them

http://matplotlib.sourceforge.net/screenshots.html

If you want low level control over raster graphics, you have lots of
choices.  pygtk with gtk.gdk.Drawable and gtk.DrawingArea is one that
is fast and cross platform; it also comes with nice widgets.  A wx
canvas is another alternative, or PIL, or .....

JDH




More information about the Python-list mailing list